English Level

February 1, 2010 English, Success 5 comments

Point 6 in my Where Do You Want to Be In a Year? is:

“Improve my English skills to have at least upper-intermediate strong level (according to my company graduating)”

Previous Level: Intermediate
Last year my level was evaluated as Intermediate, but since that time I had a lot of experience of communication with native speakers. So I was pure much sure that my language is improved. I requested reevaluation, which occurred last week.

How was it?
I’ve drank too much coffee before came for my reevaluation, so my voice was a bit hoarse. Not a plus.
We spoke a bit, I mentioned about that I requested this reevaluation and why do I need that. Then she gave me feedback and proposed me to pass some test.

Feedback
Before test she said that my English level is not upper-intermediate definitely :( , and she explained why:
1) I repeated same words to much.
2) I do not use enough  adjectives.
3) My speech is not fluent.
For upper-intermediate my English should be fluent!

Exercise for me
When I speak I should think not only about what I speak, but also how I speak.

Result
Current Level: Intermediate Strong

English courses
Also, I’m eligible  for English courses in my company, so I moved to upper-intermediate course. This means that course could improve my skills to that level, of course if I’ll be a good student. I really need this study, even if it will be taking some time. I know that to compel myself learning that alone will not succeed. I’ve decided that course will help me with this just fine.
 
I’m on the way to have desired level of English, so will learn hard to have
Future Level: Upper-Intermediate Strong


5 comments


Master Diploma: Self-Organizing Maps Parallelization

January 30, 2010 MasterDiploma 1 comment

It’s time to start seriously work on my Master Diploma.

What about is my Master Diploma work?

In Artificial Intelligence we often use neural networks in try to simulate aspects of the biological neural networks. Applicability of these is very wide, it could be smart unit in some video game, or expert subsystem when diagnosis patient. Even your inbox e-mails are filtered with algorithm, which includes neural networks usage.

One great applicability of Self-Organizing Maps (one of the artificial neural networks) is possibility to analyze high-dimensional data, save its topology and translate it to low-dimensional representation which further could be easily analyzed by human brains.

For human being it is hard to work with dozens of input information for different aspects of one thing. For example 100 patients being diagnosing and for each we need 30-40 different measurements. SOM could easily classify data and for output with knowing of some existing diagnosis we can get “Patient – Diagnosis”.

I mentioned something like “with knowing of some existing…”. This means that SOM requires training, which takes execution time. If our application domain is something for military, time could be critical constraint.

In this work I’m going to significantly improve calculations of Self-Organizing Maps with introducing multi-threading improvements.

Project hosting

I already hosted my project with google code:
http://code.google.com/p/andriybudaydiploma/


Code:
The
self-organizing map is a popular unsupervised neural network model for
high-dimensional data analysis. However, the high execution times
required to train the map put a limit to its use in many application
domains, where either very large datasets are encountered and/or
real-time response times are required.

Project is host for implementation of a parallel algorithm, purpose of
which is to significantly improve calculations of standard algorithm.
This is main goal of actual project.

This project represents Andriy Buday’s Master Diploma work.

e-mail me: andriybuday@gmail.com

What do I need to accomplish?

I need to ensure that I understand computations of SOM deeply.
Research over interned for similar works and take them into account.
I’ve decided to write my code from scratch, since I already have some implementation of SOM.
After I’ll have some implementation I need to analyze results I got on different systems.
Improve my knowledge of Java, Concurrency and train my scientific habits. :)

This blog and my Diploma

I was thinking about posting status of my work on Diploma on separate blog or site, but don’t want to have myseft scattered over different locations, so I’ve decided that just tag “Master Diploma” should be enough. I don’t think that it could make sense to hide something from the world or my co-workers or Customers (don’t even think they read my blog). And of course my Diploma is part of my Road To Success.

Please, wish me luck on this!

No doubt I will do the best to take my work to the breakthrough.


1 comment


Builder

January 29, 2010 Design Patterns, Java No comments

Imagine that you have shop where your Customers could buy Laptops with configuration they prefer. You need to develop system which will allow you easily build any configuration of Laptop for any User.
How could you easily accomplish this?

BUILDER

Builder is Creational Design Patter which allows you build some whole Product (Laptop) by constructing together some parts like Processor, Memory, Monitor, HDD, Battery and so on.
So your employee talks to Customer and asks questions which memory do you want and so on. Or otherwise if Customer is not technic, employee could ask “Do you need this laptop for gaming?”.
So you need some steps to construct you computer and they are defined in Abstract Builder.

Code:

/** Abstract Builder */
public abstract class LaptopBuilder {
    protected Laptop laptop;
   
    public void createNewLaptop(){
        laptop = new Laptop();
    }

    public Laptop getMyLaptop(){
        return laptop;
    }
    //mentioned steps to build laptop
    public abstract void setMonitorResolution();
    public abstract void setProcessor();
    public abstract void setMemory();
    public abstract void setHDD();
    public abstract void setBattery();
}

 If your Customer answers like “Yes, I wanna play… play…!!!“. You already have implementation of Concrete Builder for gaming laptop like:

/** Concrete Builder */
public class GamingLaptopBuilder extends LaptopBuilder {
    public void setBattery() {
        laptop.Battery = “6 lbs”;
    }
    public void setHDD() {
        laptop.HDD = “500 Gb”;
    }
    public void setMemory() {
       laptop.Memory = “6144 Mb”;  
    }
    public void setMonitorResolution() {
        laptop.MonitorResolution = “1900X1200”;
    }
    public void setProcessor() {
        laptop.Processor = “Core 2 Duo, 3.2 GHz”;
    }
}

Or if you Customer is business guy and he watches presentations and exel reports in plain:

Code:

/** Concrete Builder */
public class TripLaptopBuilder extends LaptopBuilder {
    public void setBattery() {
        laptop.Battery = “12 lbs”;
    }
    public void setHDD() {
        laptop.HDD = “250 Gb”;
    }
    public void setMemory() {
       laptop.Memory = “2048 Mb”;
    }
    public void setMonitorResolution() {
        laptop.MonitorResolution = “1200X800”;
    }
    public void setProcessor() {
        laptop.Processor = “Celeron 2 GHz”;
    }
}

To manage steps to build your Laptop basing on the answer you need Director:

Code:

/** Director */
public class BuyLaptop {
    private LaptopBuilder laptopBuilder;
   
    public void setLaptopBuilder(LaptopBuilder lBuilder){
        laptopBuilder = lBuilder;
    }
   
    public Laptop getLaptop(){
        return laptopBuilder.getMyLaptop();
    }
   
    public void constructLaptop(){
       
        laptopBuilder.createNewLaptop();
       
        laptopBuilder.setMonitorResolution();
        laptopBuilder.setProcessor();
        laptopBuilder.setMemory();
        laptopBuilder.setHDD();
        laptopBuilder.setBattery();
    }
}

Here we have usage code.

//Your system could have bulk of builders
TripLaptopBuilder tripBuilder = new TripLaptopBuilder();
GamingLaptopBuilder gamingBuilder = new GamingLaptopBuilder();

BuyLaptop shopForYou = new BuyLaptop();//director

shopForYou.setLaptopBuilder(gamingBuilder);//Customer answered that he wants to play
shopForYou.constructLaptop();

Laptop laptop = shopForYou.getLaptop();//just get what he wants
laptop.print();

Output:

Laptop: 1900X1200, Core 2 Duo, 3.2 GHz, 6144 Mb, 500 Gb, 6 lbs

Easy, simple and great pattern. 

What have I learned regarding of Java?
Nothing special, just how to format strings:

Code:

System.out.print(String.format(“Laptop: %s, %s, %s, %s, %s”, MonitorResolution, Processor, Memory, HDD, Battery));


No comments


Eric Evans: Domain-Driven Design

January 29, 2010 Book Reviews No comments

Domain Driven Design by Eric Evans is one of the books that every architect must read if he wants to develop really extensible enterprise level application, which absorbs knowledge of the problematic domain.

Book talks about Ubiquitous Language which is the language between Domain Experts and Developers and helps them build model of the application.

Once you have this language you could easily start build your model with Entities and Value Objects, making Associations between them and other elements of the system. Then you use Services to apply operations on your domain. To interact with Infrastructure you need Repositories and Factories, this makes Persistace Ignorance Layer to hide and isolate your model from technical impacts of your infrastructure.

Refactoring Toward Deeper Insight plus Distilling of model takes your system to the breakthrough. If you have clear model, future Developers could easily work with it addin new functionality and speaking with Customer on common language they will know it, because code raises it to them.

This is one of most valuable book I’ve ever read!



No comments


Session.Merge(object obj) to RESCUE

January 29, 2010 Errors, NHibernate No comments

Error:

“a different object with the same identifier value was already associated with the session: 14, of entity: Developer.RoadMap.To.Success.Entities.Customer”

I had something like this in the SaveCustomer method:

if ( customer.CustomerID > 0 )
{
    Session.Update( customer);
}
else
{
    Session.SaveOrUpdate( customer);
}
transaction.Commit();

And this don’t work correctly. Simple change to

if ( customer.CustomerID > 0 )
{
    customer = Session.Merge( customer );
}
else
{
    Session.SaveOrUpdate( customer);
}
transaction.Commit();

resolved my issue.


No comments


Event Name: CLR20r3

January 27, 2010 Deployment, Errors 2 comments

I got error which says “MyApplicationName has stopped working” once deployed simple tool application to the deployment machine which is MS 2008 Server.

But application works just fine on my Dev Machine.
I took a look on event viewer and it says:

Fault bucket 952814299, type 5
Event Name: CLR20r3
Response: None
Cab Id: 0

Problem signature:
P1: myapplicationname.exe
P2: 1.0.0.0
P3: 4b607991
P4: MyApplicationName
P5: 1.0.0.0
P6: 4b607991
P7: 83
P8: f
P9: System.IO.FileNotFoundException
P10:


It looks like something I was referencing is something in the framework that wasn’t installed on the server.
But what?

I remembered that when worked with UI I inadvertently took some thing from ToolBox. I immediately removed that thing, but REFERENCE were left in projects references.
It was Microsoft.VisualBasic and Microsoft.VisualBasic.PowerPacks.Vs.

Moral:
Once you get errors on deployment machine check carefully if you haven’t referenced something that is not needed. And remember about Event Viewer.


2 comments


Managed Extensibility Framework

January 27, 2010 .NET, Frameworks, MEF 4 comments

MEF is the Framework which allows you to load extensions to you application easily. It does discovery and composition of parts you need to be included in your application at run-time. You could extend your behavior simply with adding new Plugin. Managed Extensibility Framework will do everything for you.

Hello MEF World!

Assume we have really simple application and we want it to say “Hello MEF World!“:

    class Program
    {
        static void Main(string[] args)
        {
            var program = new Program();
            program.Run();
        }
        private void Run()
        {
            ProgrammGreeter.SayHello();
        }
        protected IGreeter ProgrammGreeter{ get; set;}
    }
    public interface IGreeter
    {
        void SayHello();
    }
    public class Greeter:IGreeter
    {
        public void SayHello()
        {
            Console.WriteLine(“Hello MEF World!”);
        }
    }

That is absolutely how this look and we want to make this work. The main issue is to have instance in property ProgrammGreeter to be real instance of Greeter.

Lets accomplish this with MEF

In order to do this we need to include reference to System.ComponentModel.Composition.

Accordingly to MSDN: “MEF is an integral part of the .NET Framework 4 Beta 1, and is available wherever the .NET Framework is used. You can use MEF in your client applications, whether they use Windows Forms, WPF, or any other technology, or in server applications that use ASP.NET. In addition, there are plans to add MEF support for Silverlight applications.

Most likely MEF will be included into .NET Framework 4.0, but for now we could download it from codeplex site here.

Once we added reference we could add Import and Export attributes.
Export stands for exposing some capabilities and Import stands for dependency on some other capability.

Our Greeter provides some capabilities so we add Export there:

    [Export(typeof(IGreeter))]
    public class Greeter : IGreeter

We want to use that capability in our Programm class, we depend on that functionality. Add Import:

        [Import]
        protected IGreeter ProgrammGreeter { get; set; }

Usually our capabilities lives in other asseblies, but also they could live in called assembly. Anyway we need to say how to compose all our dependencies to MEF.
This could be done with method Compose which we be calling before we are using capabilities, usually at the start of app:

        private void Run()
        {
            Compose();
            ProgrammGreeter.SayHello();
        }
        private void Compose()
        {
            var assemblyCatalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
            var compositionContainer = new CompositionContainer(assemblyCatalog);
            compositionContainer.ComposeParts(this);
        }

I ran my application and got:

How does Managed Extensibility Framework work?

I think that you are bit concerned/confused regarding that Compose method. Just read comments in code of Compose, which I made more detailed:

        //We need guide MEF how to Compose all we need
        private void Compose()
        {
            //Catalog says where to search for capabilities (Where do exports live)
            var assemblyCatalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
            //CompositionContainer holds defined dependencies and coordinates creation
            var compositionContainer = new CompositionContainer(assemblyCatalog);
            //CompositionBatch object holds references to all objects that need to be composed
            var compositionBatch = new CompositionBatch();
            //one of such objects is Programm instance (this), it needs to be composed
            compositionBatch.AddPart(this);
            //And finally Container has method called Compose to do actuall Composing
            compositionContainer.Compose(compositionBatch);
        }

In Managed Extensibility Framework there are primitives called ComposablePart which holds extensions to your application grabbed from Catalog. But also it might be that they have Imports which also needed to be composed.

Take a look on this picture from Managed Extensibility Framework wiki page.

More complex Example

In this example we will have application which parses XML file (contains information about some developer). Then when we want to deploy our application to Clients we want that XML to pass some rules, but they could differ from Client to Client. To accomplish this we put rules into separate dll and will work with it as with plugin.

We have two assemblies:

  • MEF.DEMO which declares ISecurityRule and IDataRule.
  • MEF.Rules has implementation of those interfaces.

Like on picture below. I simply don’t want to bore you with explaining of Rules logic. If you want sources just ping me.

Our Programm class wants to load rules from other assembly so we put Imports.

        [Import]
        public ISecurityRule SecurityRule { get; set; }
        [ImportMany]
        public IDataRule[] DataRules { get; set; }
        public void Run()
        {
            Console.WriteLine(“Programm run.”);
            Compose();
            Console.WriteLine(“Composition completed.”);
            var document = XDocument.Load(“developer.xml”);
            Console.WriteLine(document.ToString());
            var passesValidation = SecurityRule.PassesValidation(document);
            Console.WriteLine(string.Format(“Rule {0}: {1}”, SecurityRule.GetType(), passesValidation));
            foreach (var d in DataRules)
            {
                var valid = d.IsValid(document);
                Console.WriteLine(string.Format(“Rule {0}: {1}”, d.GetType(), valid));
            }          
        }

As you noticed we are using ImportMany, name says for itself.

We need to change our Compose method to search for Exports in Directory where execution assembly is located. For that we use DirectoryCatalog.

        private void Compose()
        {
            var catalog = new DirectoryCatalog(Environment.CurrentDirectory);
            var container = new CompositionContainer(catalog);
            container.ComposeParts(this);
        }

Put those dlls in one folder, and run MEF.DEMO. You will get:

The goal of MEF is to seamlessly glue together classes which import services from other parts of the application, and some classes which export those services. You could say that MEF is like DI container. Yes it has a lot of it, but Managed Extensibility Framework is concentrated on composition. And that composition could be done at run time at any point of time you want that to happen. Also you could do re-composition whenever you want to do that. You could load capabilities with Lazy technical or add some metadata to your exports. Discovering of dependencies in Catalog could be done with Filtering.

Managed Extensibility Framework is great feature, that Microsoft added to .NET 4.0 Framework.


4 comments


Button in pressed/unpressed state in System.Windows.Forms

January 26, 2010 QuickTip, UI, WindowsForms No comments

Do you want to see your button to be in pressed or unpressed state when you hit it once?

Did you catch that this behavior is not really button’s behavior – it is more checkBox’s behavior.

So to accomplish your goal you need move checkBox to your form and set appearance from “Normal” to “Button”. Like here:

System.Windows.Forms.CheckBox checkBox1 = new System.Windows.Forms.CheckBox();
checkBox1.Appearance = System.Windows.Forms.Appearance.Button;

Kick me if you don’t want to see such posts on my blog. :)


No comments


I Increased posting frequency

January 26, 2010 Opinion, RandomThoughts, Success No comments

I have 18th post this month that is more than in past three months. This means that I increased frequency of posting and I think that did not lost quality of its content. What do you think?

I think I’m good on this. I also increased amount of blogs I read (near 30).

Why do I think that blogging helps me?

  • I’m learning how to express my thoughts.
  • I grab only consistent knowledge on themas of my posts. This means that I do good research over internet before posting something.
  • After I posted something I leave a good knowledge portion left in my mind.
  • My blog will grow and I will get more readers so will be more famous. People needs this sometimes.
  • This blog also could be a good visiting card for my further career.

To get more readers I need to have some certification that my blog is good to read and this could be reached only if I will continue learn something.

I also found one interested post where guy explains why Why Blog Post Frequency Does Not Matter Anymore. Yes, but my blog has defined content boundary and my posts are not something like posts on twitter, so I believe that it will lead me to Success.

BTW: If you are one of the guys who think that I’m too small fish to read my blog I would say: “Follow me and see if you will be so fast all the distance as I will be.”

Honestly I think we should see people in light of theirs attitude to something, but not in light of theirs knowledge of something.

Leave your comment with link to your blog. I will follow you immediately. ;)


No comments


Specification

January 25, 2010 Design Patterns 3 comments

SPECIFICATION

Generally saying Specification is a predicate that determines if an object does or does not satisfy some criteria. By using Specifications you could easily recombine business logic together using boolean logic.

Have you ever thought that bool TryParse(string s, out int result) could be seen as some pattern? Yes we could talk about this method like about specification of integer represented in string, and this is validation usage. This pattern also could be used not only for Validation, but also for Queuring and Building purposes.

Let us imagine that we need to validate if some Patient is eligible for drugs procedures at home provided by nurse.

So this we will need two specifications. If they are both satisfied we could say that this patient is eligible for drugs procedures at home.
 
First specification

    public class EligibleForDrugs : ISpecification
    {
        public bool IsSatisfiedBy(Patient patient)
        {
            return patient.IsActive && patient.HasPayer;
        }

    }
 
Second specification

    public class EligibleForNurseVisit : ISpecification
    {
        public bool IsSatisfiedBy(Patient patient)
        {
            return patient.IsActive && patient.IsAtHome;
        }
    }

As you guess ISpecification interface looks like:

    internal interface ISpecification
    {
        bool IsSatisfiedBy(Patient patient);
    }

Usage could look like:

        public List<Patient> FetchPatientsForVisitWithDrugs(List<Patient> patients)
        {
            var eligiblePatients = new List<Patient>();
            ISpecification drugsSpec = new ElegibleForDrugs();
            ISpecification nurseVisit = new ElegibleForNurseVisit();
            foreach (var patient in patients)
            {
                if(drugsSpec.IsSatisfiedBy(patient) && nurseVisit.IsSatisfiedBy(patient))
                {
                    eligiblePatients.Add(patient);
                }
            }
            return eligiblePatients;
        }

You could say that we can put all verification in our method FetchPatientsForVisitWithDrugs. Yes, but this is not right way, because your specifications could be used in different locations and also if see this from DDD perspective you always need to bring concept things into the light.

Another question: Don’t you see this systax
if(drugsSpec.IsSatisfiedBy(patient) && nurseVisit.IsSatisfiedBy(patient))
to be boring systax? Yes, especially if you have many specifications.

Let us improve our design.

First we will add some methods to our interface like here:

    public interface ISpecification
    {
        bool IsSatisfiedBy(Patient patient);
        ISpecification And(ISpecification secondSpec);
        ISpecification Or(ISpecification secondSpec);
        ISpecification Not(ISpecification secondSpec);

    }

And also will add CompositeSpecification which will be abstract  base class for our two existing.

    public abstract class CompositeSpecification : ISpecification
    {
        public abstract bool IsSatisfiedBy(Patient patient);
        public ISpecification And(ISpecification secondSpec)
        {
            return new AndSpecification(this, secondSpec);
        }
        public ISpecification Or(ISpecification secondSpec)
        {
            return new OrSpecification(this, secondSpec);
        }
        public ISpecification Not(ISpecification secondSpec)
        {
            return new NotSpecification(secondSpec);
        }
    }
Classes returned by different method of this new CompositeSpecification are used to combine few specifications in order to build new complicated one. They could look simple like this AndSpecification class:
    public class AndSpecification : CompositeSpecification
    {
        private ISpecification firstOne;
        private ISpecification secondOne;
        public AndSpecification(ISpecification firstSpec, ISpecification secondSpec)
        {
            firstOne = firstSpec;
            secondOne = secondSpec;
        }
        public override bool IsSatisfiedBy(Patient patient)
        {
            return firstOne.IsSatisfiedBy(patient) && secondOne.IsSatisfiedBy(patient);
        }
    }

Let’s move to our existing specifications and how they changed with our new design:

    public class EligibleForDrugs : CompositeSpecification
    {
        public override bool IsSatisfiedBy(Patient patient)
        {
            return patient.IsActive && patient.HasPayer;
        }

    }

This all gives us ability to have build specifications quering in more sweet way.
New Usage

            ISpecification specification = new EligibleForDrugs()
                                           .And(new EligibleForNurseVisit());

Now we work with this new specification as with simple single one: if(specification.IsSatisfiedBy(patient))
With other specifications like OrSpecification and NotSpecification we could build more complicated queries.

For example I will show some possible usage of this in Nhibernate:

        public DetachedCriteria PatietQuery(DetachedCriteria criteria)
        {
            criteria.Add(criteria.EqualTo(“patient.IsActive”, true));
            criteria.Add(
                    Expression.Not(
                        Expression.Or(
                            Expression.Eq(“patient.Type”, PatientStatus.Discharge),
                            Expression.Eq(“patient.Type”, PatientStatus.Death)
                        )
                    )
                );
            return criteria;
        }

Advantages of the Specification:

  • Specification declares requirements to the output but do not expose how those results are reached.
  • Rules are defined explicitely. This means that developer could know what to expect from the specification even without knowledge how that is realized.
  • You get flexible interface, which could be easily enhanced. You also could build your composite specifications for queuring.
  • Another good advantage is possitility to test everything easily. You just define fail, non-fail states of the object and verify by checking boolean result.


3 comments