Monday, January 10, 2011

How To Write Good Code - Diagram

How To Write Good Code Funny Stuff...



source.

Hope you're having a good time,
Elad Shalom,
CTO at ITweetLive.com

IronRuby and Visual Studio 2010 - Integration

IronRuby and Visual Studio 2010.

The IronRuby represents another one of Microsoft's attempts to have it all under one development environment.
  • C / C++
  • VB.Net / C# / F#
  • J#
  • Their latest integration with jQuery
  • IronPhyton
And now - IronRuby.

This addition is brand new and a very cool one.  The add-on for Visual Studio 2010 is exactly for those who like Ruby and wish it to be implemented in their .Net environment when needed.

This IronRuby release (1.1.1) with Visual Studio 2010 integration includes:

  1. Ruby colorized and syntax checker.
  2. Interactive loop window.
  3. Directory based projects.
  4. Templates for common Ruby applications (including Ruby on Rails 3, Sinatra, Gems and Silverlight based browser scripting app) 

 Source by Christopher Bennage.

Thanks,
Elad Shalom,
CTO at ITweetLive.com

Multiple Solutions with the Same Structure - Visual Studio 2010 How To

Duplicating Solutions in Visual Studio 2010.

As you probably know, I work in a company that provides sports betting solutions for many companies.  Each company has its own GUI and sometimes different flows inside the site.

This is basically not hard to manage as long as you create a proper Skeleton Solution.

A Skeleton Solution is a solution contains only the most relevant files and folders.  The same classes and JavaScript files that exist in every other solution.
A Skeleton Solution will contain, in most of the times, several projects.

I believe you've read my article about File Sharing in VS 2010.
This article is in some way an extension of the one I just mentioned.

How to Create a Skeleton Solution from an Existing Solution:
It's even easier then you think.
  1. Create a folder named: "Base Solution" or "Skeleton Solution".
  2. Copy the content of your existing solution's folder.
  3. Paste the content inside your Skeleton Solution's folder.
  4. Change the names of:
    1. ".sln" file to "Skeleton.sln"
    2. ".vssscc" file to "Skeleton.vssscc"
    3. You can delete the ".sue" file.
You now have a working copy solution of your existing one.
Now you have to make it a truly Base Solution:
  1. From the Skeleton Solution, delete the files you intend to share.
  2. Now add them from your existing solution "as Linked Files".
That's it.
Your Skeleton Solution is ready. Every solution you will create from it will have the same files and projects is the Skeleton Solution.

More over...
The copied solutions will also have the same linked files as the Skeleton Solution in the exact same format.

This method will save you lots of precious time and even more important - will save you potential errors.

Thanks,
Elad Shalom,
CTO at ITweetLive.com

Sunday, January 9, 2011

Refactoring - Manage Your Code and Layers

Refactory - Design Improvement of the Existing Code.

When I say Code Management most people tell me "I know exactly what I wrote... I know exactly where everything lays".

Well.. This sentence usually takes me back to when I was 6 or 7 years old.  My mother used to tell me to clean and organize my room  and that's exactly what I told her...:

"But mom...  I love it when my soldiers are under the carpet, my school books are in the closet, my clothes are on my library and my shoes are where my action figures were.

I'm pretty sure most of you are nodding and agreeing with me.
But this is wrong.

Back to development then...
There are several file types that should be in a unique folder (for each) in every project:

   1. JavaScript
   2. HTML
   3. CSS

JavaScript should not be inside "script" tag.
CSS should not be inside "style" tag nor inside the element it's affecting.
And HTML... Well... HTML should be on his own.

Now I want to talk a little about Classes.
In every language we write we should have different classes to achieve different functionality.

One of the most important Classes out there is the DB Layer - Data Base Layer.
Lets go over the basic terms:
  1. DBLayer - a class containing calls for the Views or Stored Procedures in the database.
  2. Stored Procedure - SP - a function inside the database which designed to insert / update / delete / select from a table or from a number of tables.  Stored Procedures can also return DataSet / DataTable / String / Int / DateTime according to specific parameters.   
  3. Views - A View is a static query designed to be activated without any major changes (a view won't usually accept parameters.  Store Procedure will).
So, Back to the Management of the Code.

The basic level is the GUI - Graphic User Interface - Meaning, what the user see and work with.
The GUI is basically the HTML and CSS (in website development).

After that, we have the Client side code - Scripts - JavaScript.
The JavaScript should usually be the one (or plain HTML elements "OnClick" attributes) to activate the code behind functions.

After a Client Side element calls a Server Side function - the function should preform it functionality.  Meaning, run through the code.
In most of the cases, a large part of the functions involve calling the datalayer.

The Data Layer Class (or as I call it "DBLayer") contains all the functions that should call the database.  Since we want a neat and tidy code, we wont write Select / Insert / Update / Delete / Drop inside the code.
This is not meant only for a clean code, this code moderation is basically for security reasons.

Example?
Lets say you have several projects that use the same data base.  On one of these projects you have a friend working with.
Giving him full access permissions to Drop and Truncate Tables is not the best idea.

Eventually, the whole point of this post was to give a short explanation of how to correctly moderate your code.  How it should be designed.

If your code isn't designed that way - That's the exact point of Refactoring..
Changing the design of the existing code without altering it's functionality.

Thanks,
Elad Shalom,
CTO at ITweetLive.com