четверг, 22 августа 2013 г.

Happiness the way I see it

Recently, I have noticed a movie on TV. It is a pity that I didn’t hit at the very beginning and didn’t see the name of it. The movie was a bit boring and monotonous, but it was impossible not to be watching it. The picture was like this: A monk and a young guy are going up the rocks on the hill. All the way monk tells the guy that when they reach their destination to the top of the mountain - they see something quite extraordinary, something supernatural, incredible, but did not say specifically what it should be. The path to the top is very long and complicated to go. They are talking about life on different topics... A monk asks the young man: "Are you happy?" He answers: "Now, we are going such a huge way, and we will open something amazing. Yes, I am happy." Next, at some point, monk stops and says: "Well, we have reached the destination." The guy turns around and asks: "So what? What is incredible?" The look of monk stops at some stone: "Well, let’s take for example this stone. It's perfect." Man with a disappointed face asks the monk: "And we have walked for so long only in order to see some common stone. Are you kidding me?" Monk responded: "But were you happy and did you enjoy the way you overcame?"
This movie made me think over what true happiness is really about and why some people are unhappy. Many philosophers and books assert that happiness is manifested only in special moments and did not stay for long with us. I see happiness as a substance, abstract and even infinite or recursive process. But as with any process, the "happiness" process must have some effect (the task, purpose, destiny if you want). While the young man was going to something unimaginable, to the fact that he wants to see, he was happy throughout even extremely complicated way. I identify the place where he was going - like a dream, and his way to the top - happiness. That is, true happiness is impossible when there is no dream, while the "dream come true" isn’t so important, because you've already worked this way to a dream, and you are happy. Happiness is not a goal in itself, it is a movement to it.
So, to be happy, you need to find a dream to follow the right way and enjoy it.
Why are some people unhappy then? Don’t they have dreams? If you think so, this is partly true. If you look at the life of an ordinary person not from a rich family, who is working every day and hates his job, who stays working at night to feed his children, he gets tired, he has money just enough to pay for the food and the flat, which he has been saving all his life... In this situation, the meaning of a person's life – “Live - to survive”. And unfortunately, it's not uncommon. It’s very difficult in this situation to find the strength to do something, and in general, to find the desire even to want something. And in fact, it is a problem. For every person in the world under all circumstances, no matter how hopeless it may seem, the potential dream of his life surely exists to open the happiness way if he looks carefully.
Some kind of person has many small pleasures in his life, which are forgotten very soon, and all again continues to be boring. Happy person faces some unpleasant things, happening frequently, overcomes it soon and continues enjoying his life again.

четверг, 25 июля 2013 г.

18!

Well, I'm eighteen by now. I have imagined this moment in a different way. In fact, everything turned out to be pretty well. I am glad that I am me and not someone else. So, here are just my thoughts. It has no value for others, but a great matter for me.
Confirmed one amazing thing which I hadn’t believed in earlier. I realized that an ideal does exist and I'm convinced of this. It exists, but it is not achievable (as always :) I am lucky. At least, I can’t do that, though I have a huge desire. Perhaps this is just a bad joke of the energy conservation law. But, if it still subsists, then maybe the fact of its inaccessibility can be fixed somehow. Or not, maybe the perfect is to be so abstract, so that one can only dream of it. But I hope for the opposite :)
Sometimes I make rules for myself, when I repeat the same mistake several times. I am very easy to become attached to people. Perhaps this is part of my kind and naive character (and modest of course :). But the fact is that if a person starts to occupy a large part of your heart, when he disappears from your life, even for a short time, you miss him very very much and feel that something important is missing from you, it hurts. So I'm struggling not to get used to someone, I don’t know whether it's right or not, but when you're attracted to person, it's hard to resist. Anyway, this life is not so interesting, when you don't have someone to be inside your thoughts :)
Some moments I catch myself thinking, e.g. when I want to do something, but I know that I can't. Why can not we? Because. You just can’t. Nobody behaves such a way. What people would think. Bla-Bla-Bla. So - this is complete garbage. There is no the word "you can't". If you need it, or really want it -> it IS allowed (not speaking about violations of the law). And you don't have to be cared of any common principles and even social norms. Every single creature has an opportunity to go its own way. Generally every time there's a word you can not, ask yourself: 'what the hell'. You'll have a different view on the problem after. I actually believe that it’s possible to achieve dreams. You just need a clear plan, and strictly to follow it all the time to go through it, and never to stop going. After all, if there is a destination on the map, then in order to get there you just have to go, and sooner or later you find yourself where you want. I now have the advantage, and it is due to the fact that on my way there was nothing superfluous, and it saved me a lot of precious time that can be spent usefully. Strange, isn’t it? Looking at a sweet lovely girl nobody suspects that she grows wiser and wiser and wiser every day. I get pleasure from the fact that I'm drawn to it and I'm getting smarter. Recently caught myself thinking that sooner or later I'll have to get married, have kids (no, no, not in the sense that I do not want it - on the contrary :), and I have to stop programming, I just won’t have enough time. Sad … But now I can do it as long as I wish, and most importantly - What I wish. It is so encouraging that there is a technology! I believe that it will be even possible to download food soon, just not sure whether it’s possible biologically or chemically to know the composition and the DNA of the substance and to express it with some formula. If you're engaged in an interesting affair, you can head and share a lot of amazing things. Especially when there are no distractions. I want to raise a force of character and try to keep concentration for a long time, not wasted on some small things. Some days I’m checking my e-mail with 5-minute interval, want to get rid of it.
Actually, I have great plans for the future life. To implement the most impressive of my ideas, to run my projects on, to speak at the conferences, to write a book, maybe to teach programming at the University and engage in research, to visit the most interesting beautiful places in the world, to taste the most delicious and unusual dishes, finally, to go to the rock 'n' roll concert, visit Disneyland, to touch the clouds form an air balloon, to catch a salmon from the yacht, learn to play snooker, fall in love forever and many many another things :)

четверг, 30 мая 2013 г.

WCF Quotas

When using WCF and transferring rather big objects or collection of objects or objects with a big amount of inner properties through the network, you can encounter a problem something like here:

Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service

The underlying secure session has faulted before the reliable session fully completed. The reliable session was faulted.

Server stack trace:
   at System.Runtime.InputQueue`1.WaitQueueReader.Wait(TimeSpan timeout, T& value)
   at System.Runtime.InputQueue`1.Dequeue(TimeSpan timeout, T& value)
   at System.ServiceModel.Channels.InputQueueChannel`1.Dequeue(TimeSpan timeout, TDisposable& item)
   at System.ServiceModel.Channels.DuplexChannel.TryReceive(TimeSpan timeout, Message& message)
   at System.ServiceModel.Dispatcher.DuplexChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation,
   Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,
   ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
                                                                         …
When starting WCF service locally – the exception disappears and everything works clearly.
Here are quotas on the level of binding:
MaxBufferPoolSize, MaxBufferSize, MaxReceivedMessageSize, MaxArrayLength, MaxBytesPerRead, MaxDepth, MaxNameTableCharCount, MaxStringContentLength.


Another point is that WCF uses dataContractSerializer or xmlSerializer when transferring objects. DataContractSerializer has maxItemsInObjectGraph property limit. It has 65535 value by default.

Here is possible solution for this problem:

1.      In your server configuration file (App.config/Web.config) find your binding and set required properties that override default values and add dataContractSerializer setting in serviceBehavior section:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
<behaviors>
      <serviceBehaviors>
        <behavior name="Common">
          <serviceMetadata httpGetEnabled="false"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
        <bindings>
               <netTcpBinding>
       <binding name="YourBindingName"
                        maxBufferSize="2147483647"
                        MaxBufferPoolSize ="2147483647"
                        maxReceivedMessageSize="2147483647"
                        openTimeout="00:10:00"
                       receiveTimeout="00:10:00"
                       transactionFlow="true" >
          <reliableSession enabled="true" inactivityTimeout="00:10:00"/>
          <readerQuotas maxStringContentLength="2147483647"
                                      maxArrayLength="2147483647"
                                      maxBytesPerRead="2147483647"
                                      maxDepth="2147483647"
                                      MaxNameTableCharCount="2147483647"/>
          <security mode="Transport">
            <transport clientCredentialType="Windows"/>
          </security>
        </binding>
               </netTcpBinding>
        </bindings>
<services>
      <service behaviorConfiguration="Common" name="YourServiceName">
        <host>
          <baseAddresses>
            <add baseAddress="YourServiceBaseAddress" />
          </baseAddresses>
        </host>
        <endpoint name="YourEndpointName" address="" binding="netTcpBinding"
                           bindingConfiguration="YourBindingConfiguration" contract="YourContract" />
        <endpoint address="net.tcp://targetServer:777/Services/YourServiceName/mex"
                            binding="mexTcpBinding"
                            contract="IMetadataExchange" />
      </service>
</services>
        <client>
            <endpoint address="yourAddress"
                binding="netTcpBinding" bindingConfiguration="bindingName"
                contract="yourContract" name="endpointName">
                <identity>
                    <userPrincipalName value="yourUser@yourDomain.com" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>
2.      On the client size open configuration file and set the required options (client needs endpointBehaviors to be set):
<system.serviceModel>
    <behaviors>
    <endpointBehaviors>
        <behavior name="ClientBehavior">
            <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
    </endpointBehaviors>
    </behaviors>
    <bindings>
      <netTcpBinding>
        <binding name="YourBindingName"
          maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647"
          openTimeout="00:10:00"
          receiveTimeout="00:10:00"
          transactionFlow="true"
          transactionProtocol="OleTransactions">
          <reliableSession enabled="true" inactivityTimeout="00:10:00"/>
          <readerQuotas
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxDepth="2147483647"
                        maxNameTableCharCount="2147483646"
                        />
          <security mode="Transport">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <client>
      <endpoint
        address="YourServiceName"
        binding="netTcpBinding"
        bindingConfiguration=" YourBindingName "
        contract="YourContract"
        name="endpointName"
        behaviorConfiguration="ClientBehavior">
        <identity>
          <userPrincipalName/>
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

пятница, 26 апреля 2013 г.

JUNPATTERNS

JUNPATTERN 1.          
   
Use as many JUNPATTERNS as you can in your applications.

JUNPATTERN 2.             

Make everything public. No matter what – fields, properties, methods… If someone has the goal to hack your app – he will manage to do this anyway. So why then we need to suffer from the lack of access to something once again?!

JUNPATTERN 3.             

Make members static, if possible. Especially methods. Why do we need to create an instance of an object to access the method, if we can simply make it static and use it on the class level?! So the best solution is to make it static, believe me.

JUNPATTERN 4.           

Copy the code. So you always have needed logic in front of your eyes, without making mouse clicks in attempt to find some method. We even don’t need these complications with inheritance!

JUNPATTERN 5.           

Don’t write unit tests – they are useless. If you have written the code, you clearly know that it works splendid! Therefore – unit testing is just the waste of your time.

JUNPATTERN 6.        
     
Don’t be afraid of nested code blocks. That’s OK if you face with 10-level nested code construction. Why should we spray our important and complex business logic in different locations?!

JUNPATTERN 7.        
     
Create a special class for storing various methods. So it’s a great and convenient location to place all methods you don’t know where to place. Don’t forget to make it static!

JUNPATTERN 8.            

Always catch exceptions and use empty catch blocks. It prevents users of our application from being scared at the sight of the error message.

JUNPATTERN 9.          
   
Create methods large number of parameters, instead of separating the global task solution into separate methods with few parameters. This approach is more resultative and convenient.

JUNPATTERN 10.         
To be continued…

четверг, 11 апреля 2013 г.

Big Promise


 I give a promise that I will continue to move forward and I will do my best not to accept the compromise. I will not allow anyone to encroach upon my independence. I promise that I won't pay attention to what others think, I'll just go ahead and do what I have conceived, and deem it necessary.

воскресенье, 10 марта 2013 г.

Not what it seems


Why do I sometimes feel like laughing, but sometimes like crying? Why do factors, even in no way connected to me can affect my mood? Why I was not given full control over my emotions.. but, well, now I have a better handle. And why sometimes there is a desire to be alone, so no one will touch you – and sometimes other way round - terrible desire to be with your close friends. The first pertains to me to a greater extent. Being alone makes you the closest thing to your true inner world. When you spend a long time in solitude your worldviews are changing, your attitude to people, the view on your purpose of life, on the opinion at what you want to do – all this things become more correct.  It’s hard to live in an environment where people do not appreciate your values and beliefs. It’s nice when there is at least someone who can understand you, because he knows how difficult it is, when you are told “NO”, but you break the wall and say “YES”, when they say “No, you will never manage!”, but you reply “Why somebody can, but I can’t?”. Sometimes it even adds strength, the desire to try something unusual appears.. but sometimes pressure is too strong and it’s good to find the stamina to not break. One is invariably - I will always have difficulties and I will always have something that will interfere, so we must not think like “well, it needs just a little bit more efforts and nothing else”. Unlikely. Because something that you are doing now - this will not solve all the problems forever. So, the main is to go up and to improve yourself, enjoy every moment, as an instant of absolute happiness won’t occur by himself. 

пятница, 1 марта 2013 г.

Logging and Tracing SQL Queries using Entity Framework 5.0 Code First DbContext


During the development of my last application, I had a problem I encountered when there was a need to look at all queries to our entity framework database. After a lot of googling time I didn’t find the solution that works fine for entity framework 5.0 database code first using DbContext (not ObjectContext or DataContext). After all – I have found the  library called Clutch, that you can install via NuGet and use inside your project. The solution is very simple and elegant and only this works with the given conditions. Only thing you need to do is to implement an interface IDbTracingListener. That is how it looks like in the Clutch:


namespace Clutch.Diagnostics.EntityFramework
{
  public interface IDbTracingListener
  {
    void CommandExecuting(DbTracingContext context);

    void CommandFinished(DbTracingContext context);

    void ReaderFinished(DbTracingContext context);

    void CommandFailed(DbTracingContext context);

    void CommandExecuted(DbTracingContext context);
  }
}

So add new class to your application:

    /// <summary>
    /// Implementation of IDbTracingListener
    /// Class is used for tracing all SQL Queries to the entity framework database
    /// </summary>
    public class DbTracingListener : IDbTracingListener
    {      
        public void CommandExecuting(DbTracingContext context)
        {
            //implementation if needed here..
        }

        public void CommandFinished(DbTracingContext context)
        {
            //implementation if needed here..
        }

        public void ReaderFinished(DbTracingContext context)
        {
            //implementation if needed here..
        }

        public void CommandFailed(DbTracingContext context)
        {
            Debug.WriteLine("\nFAILED\n " + context.Command.CommandText);
            // or Trace.WriteLine("\nFAILED\n " + context.Command.CommandText);
        }

        public void CommandExecuted(DbTracingContext context)
        {
            Debug.WriteLine("\nExecuted\n " + context.Command.CommandText);
            // or Trace.WriteLine("\nExecuted\n " + context.Command.CommandText);
        }
    }

Don’t forget to add using statements:

using System.Diagnostics;
using Clutch.Diagnostics.EntityFramework;

Inside methods like “CommandExecuted” you can do everything you want with SQL statements to your DB that you can get via context.Command.CommandText.
The last thind is to enable tracing in Global.asax file in Application_Start method (for ASP.NET MVC application. For any other – do it in the entry point):

// Enable Tracing queries
DbTracing.Enable();
// Adding the listener (implementation of IDbTracingListener)
DbTracing.AddListener(new DbTracingListener());

четверг, 17 января 2013 г.

How To Start with SharePoint (Create VM, Install Windows Server, install SQL Server, install SharePoint)


Some time ago I decided to learn SharePoint. That’s the only powerful thing I’m missing in my professional .NET knowledge. SharePoint is a browser-based collaboration and document management platform from Microsoft (Wikipedia). It is a huge platform for Enterprise Content Management, Business Intelligence, simplifying search, collaboration, portal with non-trivial architecture management, integration with Exchange, Social Networking and etc. So this requires a good practice of administering Windows Server, SQL Server and so on. To get started with SharePoint, I’ve made a virtual machine on my computer where Windows Server is installed. I’ve made an instruction that works for me, and that will help my girl-pogrammer friends too. So this is the first part. It’s about how to install a VM on your computer and install Windows Server 2008 R2 OS. 


Virtual Machine

Step 1 – Install virtual machine software

Nowadays you have a large choice of VMs: HyperV, VirtualPC, VMWare, VirtualBox … Some of them are free :) It doesn’t matter what kind of it to install, though it must be 64-bit version, cos we are to install only 64-bit Windows Server inside. It’s OK if you have 32-bit OS on which you are going to install 64-bit VM. I’ve chosen the VirtualBox as a virtual machine tool to install, because it is free and rather simple to work with. It can be downloaded by following the link and selecting the appropriate version https://www.virtualbox.org/wiki/Downloads. I’ve chosen the “VirtualBox 4.2.6 for Windows hosts” variant. Then run the exe file and follow the trivial steps of the installation. Then launch the Oracle VM Virtual Box. It looks like the following (but without any created virtual machines):



Step 2 - Create your own virtual machine

At the time of writing I don’t have access to SharePoint 2013 or SharePoint 2010, unfortunately … because it costs some money. That’s why I will use SharePoint Foundation 2010, that requires Windows Server 2008 R2 or 2008 64-bit. Though we can’t use Windows Server 2012 for SharePoint Foundation 2010 – there will be pretty small difference in usage, if you manage 2010 version. SharePoint Foundation differs from SharePoint in the way that it has fewer services, limited search and account management, but in everything else it is the same.
So, click on the “New” blue round button on the top panel of the Oracle VM VirtualBox Manager. Then type the name of your new virtual machine and select the version. In my case it is “Windows 2008 (64 bit)”. Like here: 




Click Next. Select the amount of RAM for virtual machine:


Click Next. The standard option to select is “Create a virtual hard drive now”:



Click Create. Here you are to choose the format of the file for the virtual hard drive. It’s Ok to select the VDI:


Click Next. Read the description of the options and choose the way to allocate the hard drive – dynamically or fixed sized. My option is first:



Click Next. Choose the size for your virtual machine:



Click Create. That’s it! Now we have a virtual machine created, but it’s “Powered Off” now:


Step 3 – Starting created virtual machine

Now we are almost done with creating the VM, and the task is to start it, and install real Windows Server 2008 R2 inside our created VM. If you are a student, you can download it via www.dreamspark.com (it’s a portal for students with software for training purposes only), another way to get it - through your MSDN Subscription (which you can buy, for more information - http://msdn.microsoft.com/en-us/subscriptions/buy.aspx ).
After downloading Windows Server you will have an .iso or .img (if you used dreamspark) file. If you have .img – that’s Ok. But for using it for operation system on your VM you must reconvert it to .iso, using the special program.
By the way – you should make sure, that your system supports virtualization (use for example this free tool from Microsoft http://www.microsoft.com/en-us/download/details.aspx?id=592 )! Else you must enable it in BIOS. Enabling virtualization is most likely in the Security Settings tab. But it can depend – so look for appropriate system.
Done! Next – Click the “Settings” yellow button shaped situated at the top panel of the Oracle VM VirtualBox Manager. Then select the “Storage”:



Select the “WindowsServer2008R2.vdi” like the following:


Then click on the  button below the “Attributes” separation and select “choose a virtual hard disk file” option. After that choose your .iso file with Windows Server 2008 R2 that you have downloaded. Now, we are ready to start the virtual machine and install the operation system. Click on the “Start” green button shaped as a pointer.

           Windows Server
  
           Step 4 – Installing Windows Server 2008 R2.
It’s pretty simple, just follow the installation manager. The thing you must do is to select your time zone and etc:


and put in your Administrator’s new password and confirm it when asked:


Don’t do anything additional while installing, the virtual machine may restart some times while installing OS. It can take up from 30-60 minutes.
Finally you will see the desktop of your installed OS.

Step 5 – Additional check

In virtual machine choose not NAT adapter - select Bridge connection (important). To prove that everything is OK – ping from your real computer - open command line and enter: ping <your VM computer name or IP>. Press enter. If 0 packets are lost you are done. Make the same within your VM computer, but instead <your VM computer name or IP> type your real comp name. Also you will need to move some installation files from your computer to your VM (for ex. SQL Server installation, or SharePoint Foundation) if you have already downloaded it from your host (real) computer, or just download the required from guest OS (on the VM). To exchange files – use network shared folders or RDP.

SQL Server

Step 6 – SQL Server installation

To work with SharePoint Foundation 2010 you must have either SQL Server or SQL Server Express (in this case the size of DBs is limited). I have SQL Server 2008 R2 from Dreamspark – so it’s time to install it. By the way, it requires .NET Framework and you should enable it in Features of Windows Server.

-        Launch the setup.exe
In the SQL Server Installation Center window click on the “New Installation or add features to existing installation”
-         In the “Setup Support Files” window click OK.
-         Enter your product key or select free option and click Next.
-         Show your fast reading technique and accept the license agreement :) Click Next.
-       Click install.
-         Look through the warnings and click Next.
-         In the “Setup Role” window select “SQL Server Feature Installation” and click Next.
-         In the “Feature Selection” window select ALL and click Next.
-         In the “Installation Rules” window click Next.
-         Select the “Default” instance and click Next.
-         Look through the memory requirements and click Next.
-         In the “Server Configuration” window select the Service Accounts for every Service. Usually, it’s OK with NT AUTHORITY/SYSTEM, but sometimes you need to specify the Service Accounts you created in AD. Click Next.
-         In the ”Database Engine Configuration” window select Windows and click “Add Current User” as an SQL admin, or add some other account for it.
-         Go to the “Data Directories” tab and select the standard installation directories for log files, db files and backups.  Initially, everything of it is stored in one folder, but it is better to organize subfolders separately for logs, database and backup files. Click Next.
-         In the “Analysis Services Configuration” add “Current User” account as an administrator. Go to the “Data Directories” tab and select the destination directories for log files.
-         In the “Reporting Services Integration” select the standard configuration installation for the integrated with SharePoint mode. It allows to integrate report services with SharePoint. Click Next.
-         Accept everything in “Error Reporting” and click Next.
-         After the configuration rules launching click Next.
-         Look through the parameters summary and click Install.
-         When installation is finished look the log file with the results and click Close.
-         You are Done! Now you can update the SQL Server with Microsoft Update.

Step 7 – SQL Server permissions and TCP/IP enabling

The important thing to do now is to make permission for ports in firewall, which allows 1433 port to be opened (SQL port). If it is closed – SharePoint will fail to connect to SQL Server, if it is installed on another computer. Next – check if TCP/IP is enabled in your SQL Server. Go to SQL Server Configuration Manager and select the “SQL Server configuration -> Protocols” for the <your SQL Server name> element. Select Enabled for TCP/IP.

SharePoint Foundation 2010

Step 8 - SharePoint Foundation 2010 installation

Now everything is done and the task is to install SharePoint Foundation 2010.
Warning – you must have an Internet access for the installation.
-         Run the SetUp.exe for the SharePoint Foundation 2010.
-         Click “Install software prerequisites” (important)
-         When finished click Finish.
-         Click “Install SharePoint Foundation”
-         Accept the license and click Continue.
-         This step is very important! Here you are to choose the installation type – Standalone or Server Farm. Even if you are using the SharePoint as a testing server, or you don’t need additional servers – never choose Standalone variant con after that you won’t be able to add a server in the server farm. Choose Server Farm variant – with this option you ARE able to have only one server, like with a Standalone option, but you WILL be able to add a server to the server farm. So, choose Server Farm variant – you loose nothing.
-         In the “Server Type” window choose Complete (important).
-         Go to the “File Location” tab to select the place for index files. Click Install Now.

Next everything is finished and you are to select whether to launch the configuration wizard now. Advice – don’t choose to launch it, first – check for updates.

Step 9 - SharePoint Foundation 2010 configuration

Launch the configuration wizard from the start-> all programs -> SharePoint Foundation 2010 Products -> SharePoint Foundation 2010 Configuration Wizard or something like that. This wizard creates a new server farm.

-         Click Next on the greetings page.
-         Click Yes on the Message Box where it is said that IIS configuration will be changed.
-         Select Create a New Server Farm and click Next. We select it because we haven’t got another server farms yet.
-         In the “Configuration Database” type the name of your database server and the name of database for configuration. In our case we have our SQL Server on the same computer as SharePoint, so just put in your VM computer name. Click Next.
-         In the “Specify Farm Security Settings” window type the password for the farm. It is used for adding servers to the farm. Save it somewhere. Click Next.
-        Choose a port number for the administering application. You cam select from the range displayed on the window. Select NTLM for the beginning. Click Next.
-        Look through all the parameters and click Next.
-        Click Finish.

That's it - everything is ready for configuring the created server farm for your own purposes.