Tip to start VS2010 faster

by Marius Gheorghe 7. June 2010 15:50

Add “/nosplash” as a command line argument to VS2010. This shaves off a few second from the loading time .

Tags:

programming

The daily WTF

by Marius Gheorghe 5. May 2010 11:51
I enjoy reading TheDailyWTF everyday because that site represents best the real world. And darn, from a developer perspective, we live in a bad bad world Laughing

Tags:

programming

VPBO – View Presenter Business Object

by Marius Gheorghe 25. April 2010 16:43
View Presenter BusinessObject (aka VPBO) VPBO (for short) is an attempt to describe a pattern for layer structure and interaction inside of a system. It's like MVP but with a few tweaks. Notice that depending of the system, the entry point can be either the View ( in a regular ASP.NET WebForms app the request is routed to the view) or the Presenter ( in Windows Forms, WPF we call the presenter which instantiates the view).

Here's a diagram of interaction :

1. View . Responsibilities :
- describe the UI (obviously).
- basic control validation.

2. Presenter - the most important piece of the diagram. Responsibilities :
- invoke the business object(s) and get the data required by the view. Remember there is no model so you may need to invoke multiple business objects.
- data caching could be implemented here if it's necessary.
- using the view instance set the data in the view's controls.
- do logical data validation.
- pass to data back to BO to persist it.

3. Business Object. Responsibilities :
- logic goes here.


How is this different from MVP/different stuff ?
- first of all notice that there is no Model. Nor there is a interface that the View must implement. This means less code to write/change and worry about.

- from my point of view, with VPBO i'm trying to describe a way for a nice layered system implemented with the least amount of code.

- some stuff are missing compared with MVP: there isn't a way to test UI.

- should the presenter contain any kind of logic ? It can contain "logic" pertaining to his associated view. No business logic. Also this logic should be written without referencing UI controls so it can be unit tested.

- the presenter can be best described as a orchestrator. Get the BO data, display it, validate it, pass it back to BO.

- if the view is complex you are encouraged to create a master presenter along with multiple smaller presenter which handle specific UI functionality.The view knows only abour the master presenter. This represents a better way to mitigate complexity. Because "rich" UI requires a ton of code, moving that code from view to presenter(s) is a better way to mitigate complexity.

- the interaction between view and presenter can, basically, be "described" with 2 methods : Display and Save. Add more methods depending on your UI requirements. Also note that defining a interface is strictly optional.

 

Small sample using WPF here

Tags:

programming

Moved to bitbucket

by Marius Gheorghe 20. April 2010 12:38

I have decided to move my OSS projects to bitbucket.org to ease up on collaboration. I ended up choosing bitbucket because of Mercurial which is a nice DVCS (although TortoiseHg is not yet as nice as TortoiseSVN).

Tags:

programming

Model Viewer Presenter. Take 3

by Marius Gheorghe 17. December 2009 06:40

In the past months i have been implementing in my projects MVP Passive View. You can find the description here. It works pretty good (in Windows Forms and Silverlight projects) and , from my point of view, it's far better than the "other" MVP implementation because the view remains without any logic responsability.

Here's how i implement it. Basically for each view action there is a associated method in the presenter.

public class OrderViewPresenter
{
  private OrderViewDialog dialog = null;

   public OrderViewPresenter(OrderViewDialog d) 

  { 
dialog = d; 
  } 


  public void DisplayData()
 {
//invoke the Order Business Object and load the order
Order o = .......
d.textBoxOrderDate = o.OrderDate;
 }


 public void CreateNewOrder()
 {
//create the new order base on the dialog data
 }

}


No branching. You're kidding...right ?

by Marius Gheorghe 14. December 2009 17:09

In real world you get to see a lot of WTF code. A lot. And then you stumble upon things like this. It looks like Flickr doesn't do branches , has only trunk and it pushes the trunk code into production a few times a day. For any software developer that's a giant WTF moment. It simply cannot be a good ideea. 

Funny thing is that i met people who used to think that's a good ideea. I bet that when the next guy comes along will point that blog post to me and say : "But look at Flickr guys. It works for them" .  Sigh...

 

Tags:

programming

Duct tape ? No no no

by Marius Gheorghe 30. September 2009 07:30
Joel's latest piece takes the cakes as being the crappiest piece of advice. It's pretty fucked up to read development advices about Netscape developers. That's the Netscape who had a crappy codebase and crappy product (see a relation between those two ?).
Don't duct tape any code today. DO not be a "event handler programmer". Think about the future

Tags:

programming

Thoughts on code : Documenting a business software system

by Marius Gheorghe 27. August 2009 16:13

So, first of all, how would a GOOD documentation would  help us ? What would we gain from it ? Well :

- new people could be brought to speed very easely. No need to chaperon them while they understand the system, no need for different programmers to each explain to the new guy a small piece of the system.

- easy maintainance.

- remove dependency from the people who designed/understand the system.

 

Here's my take on what and how this should be done.


- document the initial requirements of the project.

- the "core" of a business system is the database schema . That's the most important thing which should be documented.  SqlDoc is a great tool for this. If you can't afford it then use a simple text editor. But DO document the schema of the database.

- document all the business procedures and requirements of the system. Some businesses have some pretty wacky procedures and requirements (if you worked with a financial system for instance, you probably already know that). Gather all these procedures and requirements and document them. Make sure the documentation is "tied" to the documentation of the database schema.

- create a entity relationship diagram.

- the most important advice of all : be explicit. Do not use shortcuts in the name of the database columns and do explain the specific business terms.

 

Thoughts on code : Comments

by Marius Gheorghe 16. August 2009 17:24

My thoughts about code comments :

- code and API comments are 2 different things and should be treated differently. 

Code comments :

- most of the time "method" comments should NOT be necessary.  Code should be written using guidelines that specify long and meaningfull names to all types. Hence if the method is called GetAvailableUsers then what's the point in adding a comment like "Gets the available users"?  The method name already tells the person who's reading the code what is does.

- comments should ONLY explain the WHY (why is the code doing this thing in this way ?). We can find the HOW just by reading the code.

- comments should be added only when there is need for them. There is no point in commenting everything (most people hate "green noise" when they read code).

- some people use comments hoping to "fix" badly written/broken code. This is SOOO wrong.  Documenting a mistake will not make it better. Consider refactoring the code and removing the comment.

- comment rot is very bad. When you refactor a piece of code, DO remove the unnecessary  comments.

- do NOT create a file header (with the name of the person who created the file, creation date etc etc). These stuff can be easely inferred from source control.  


API Comments :

- code samples are much more important than comments.  It's much more simple for the API user to have a sample on how to achieve a certain thing then to try figuring for himself by reading the API comments.

Better software with 2 simple rules/patterns

by Marius Gheorghe 5. May 2009 15:23

I'm talking about :

- DRY (Don't Repeat Yourself) - a common source of bugs in any project is duplicated code. Code which does the same thing with different implementations. The easiest way to fix this is to enforce a certain project structure : for instance in a business application all entity related task must be implemented in a single class/place/system ( call it the repository pattern, call it business object, called it whatever it tickles your fancy ...).

- SOC (Separations of concerns) - SOC is the process of designing a system in which the functionality is segregated in clearly independent (and orthogonal )  layers. This might sound more familiar by the name of some popular SOC patterns : MVP (Model Viewer Presenter) and MCV (Model Controller Viewer).  Failure in implementing a/any form of SOC results in fragile, brittle, hard to maintain (and extend) software.