Wednesday, June 8, 2011

Common Design Principles

There are number of common design principles that, like design patterns, best practice over the years to build maintainable software.

I'm up to describe some widely used design principles though out the post.

Following common principle are extracted by the same book that I mentioned before (Professional ASP.Net Design Patterns - Scott Millet).

Principles are as follows:

Keep It Simple Stupid (KISS)
One common issue in software programming is over-complicating a solution. So main concern of this principle is keep the code simple but not simplistic. Eventually this will avoid unnecessary complexities.

Don't Repeat yourself (DRY)
Main concern of this principle is to avoid the repetition. In other words this is all about abstracting out the common functionalities into a single place.
Ex: If there is a price calculation method in a system. It should lay in a single place there.

Tell Don't Ask
The Tell, Don’t Ask principle is closely aligned with encapsulation and the assigning
of responsibilities to their correct classes. This principle state that you should tell the
object to what actions that you want to perform instead of checking the state of an object and performing the action by yourself. This avoids the tight coupling between classes.

You Ain’t Gonna Need It (YAGNI)
This is about putting of any features that are going to add having the idea in mind, that you gonna need this later. A design methodology that adheres to YAGNI is test-driven development (TDD). In brief TDD is all about righting the code only to pass the test.

Separation of Concerns (SoC)
SoC is the process of dissecting a piece of software into distinct features that encapsulate unique behavior and data that can be used by other classes. Generally, a concern represents a feature or behavior of a class. The act of separating a program into discrete responsibilities significantly increases code reuse, maintenance, and testability.

So this is it.


Tuesday, March 8, 2011

S.O.L.I.D Design Principles

Hold on!!! Before this please read the common design principle post.

After a long time thought of writing a post. Actually these days I'm reading a book which is written by Scott Millet and the name of the book is "Professional ASP.Net Design Patterns". I can guarantee that this book give you a great knowledge on design stuffs.

Most of us are bit lazy to read things, so I thought of posting the things that I got form it. This is like the cream of what I got.

I'll start it with the S.O.L.I.D design principles:

The term S.O.L.I.D. comes from the initial letter of each of the five principles that were collected in the book Agile Principles, Patterns, and Practices in C# by Robert C. Martin, or Uncle Bob to his friends. Simply this is a collection of best practices for object-oriented design.

Following will explain all the principles:

Single Responsibility Principle (SRP)
This principle is closely aligned with a common design principle called Separation of Concerns. It says that every object should have one reason to change and single focus of responsibility. By applying this principle, you avoid the problem of monolithic class design. At the same time this principle gives readability and maintenance for a system.

Open-Closed Principle (OCP)
This principle says that classes should be open for extension and closed for modification, in that you should be able to add features and extend a class without it changing its internal behavior. In other words it avoids the possibilities of braking the system.

Liskov Substitution Principe (LSP)
The LSP says that you should be able to use any derived class in place of a base class and have it behave in the same manner without modification. In other words derived classes must be substitutable for their base classes.

Interface Segregation Principle (ISP)
The ISP is all about splitting the methods of a contract into groups of responsibility and assigning
interfaces to these groups to prevent a client from needing to implement one large interface and a host of methods that they do not use. The purpose behind this is so that classes wanting to use the same interfaces only need to implement a specific set of methods as opposed to a monolithic interface of methods.

Dependency Inversion Principle (DIP)
The DIP is all about isolating your classes from concrete implementations and having them depend on abstract classes or interfaces. It promotes the mantra of coding to an interface rather than an implementation, which increases flexibility within a system by ensuring you are not tightly coupled to one implementation.

This is about the S.O.L.I.D design principles. I hope this will you guys on the long way of design someday.

This is the first one of a series of articles. I'll be back with design patterns.

Tuesday, February 2, 2010

LINQ : Query expression vs Lambda Expression

All the time I was using LINQ on projects I was wondering whether there is a performance difference between query expression and lambda expression.

So I decided to dig into it. I wanted to examine MSIL for both of these situations. I wrote small class which has two methods. One is using query expression and the other one is using lambda.

code

I complied this code and got the dll and view the MSIL using ildasm.exe. This following picture will show you the MSIL of GetFirst() method.

m1

And this following picture will show you the MSIL of the GetSecond() method.

m2

Yes!!! you can see that there is no different between these 2 MSIL. Will there be a performance difference???

Friday, October 16, 2009

reCAPTCHA for ASP.NET

I was looking for this reCAPTCHA recently and this is what I found on my way. Hope this will help you in someway. To get an idea about reCAPTCHA watch the following video



and the following link will explain you how to implement it in your ASP.net web site.

reCAPTCHA for ASP.NET

Monday, July 6, 2009

Mihidum Dumaraye ( Kolapata helunu etha nimnaye) - Kasun Kalhara

You can find this song on this link
http://www.elakiri.com/forum/showpost.php?p=3006516&postcount=18

I was trying to find this and I finally found it.

Wednesday, June 17, 2009

You and Me..

Cool breeze wraps around…….
Slight showers of tiny drops
Eager to kiss the rosy petals……
Green smiles at the drizzle…….
And the golden beams illuminated…
Craft a gorgeous little world
Of hopes and dreams…..
It’s You and Me………..
Only both of us play the adoring role
In our devoted
Story of Love…………

By Thilini©

Dream

Red and blue green and yellow,
Gorgeous picture was painted,
In the vast sky of thoughts,
Hills and Dews, Wings and hopes,
Added extra brightness,
To the beautiful scenery of thoughts.
Buds and flowers, Mist and breeze,
Brought cool fresh intimacy.
Fairy queen was lost in,
One big dream.
Fresh and sweet, pretty and cool,
Little world of dreams,
Could never call Her out.
She was enjoying,
The beautiful dream,
For years……………….
And years………………
Smiles and laughter;
The bosom friends,
Who shared Her joys,
Never let the Fairy Queen,
See no tears or sorrows.
She was totally lost in
The dream fairy world,
Of which She couldn’t
See the harsh reality.
But, revealing the truth of Life,
Gloomy shadows started,
Palling on the sweet little painting.
Red, blue colors were fading,
Dark shadows were capturing,
The gorgeous dream of the fairy queen,
Bright shiny dream was leaving,
Wet little drops of tears,
Started shining at the edge
Of Her little eye lids.
But still, She is struggling,
To survive in Her cute pretty dream,
Of which She never wants to come out.
No matter what sort of a dream it is,
Be with innocent hearts forever,
Whose only happiness is a dream.


By THILINI©