Martin Spedding's Blog

Adventures in a disconnected world

Visual Studio does not lead you in the direction of layering your code

 If you are a good developer you know that you should layer your application, however, Visual Studio uses the "old Visual Basic" approach to rich client development. In other words, you create a windows form application. What does Visual Studio do, it creates a main function in the form you create first. Already that means the form is doing more than presentation. Potentially people will also write application initialisation code in this function. Ok I add a button to the form and click on it and the idea opens up the associated event routines. So far I could be writing all my business logic etc within the form.

Of course no one would do this ??? Well, how many prototypes that become production systems are written this way, it is seductive to less skilled developers.

Wouldn't it better if the tools tried to lead people to develop applications using a layed approach. It would certainly help with migration later on to Avalon.

Comments

Mehran Nikoo said:

I agree that VS.NET does not help much but I believe it is not supposed to do so. It is up to us as architects, designers and developers to have a sound architecture implemented. Ability to create sub-folders within your projects and namespaces are very useful when it comes to architecture.

.NET is unique in this way as it makes a separation between the physical view of the system (assemblies) and logical view (namespaces).

How do you think?
# April 13, 2004 4:01 AM

Frans Bouma said:

Mehran: .NET is not unique in that separation, other systems do / can do that as well.

VS.NET is an IDE, it hosts various editors for all kinds of elements. The start code you get when adding a class, form or other element might be diffrent to what people like or want, however I don't see that as a 'lead towards non-layered' software development.

The designers are good demo material, and you can use them in screenshots. However, the real power is not per se in the designers, it's in the code using the objects/defining the objects. And in there, you can design/create whatever you want.
# April 13, 2004 9:39 AM

Martin Spedding said:

Mehran and Frans for your comments.

You are right that Visual Studio allows you to design what ever you want, however, the point I was making is that when you create a winform application it leads you in the direction of building your code within the form. I know that you and I and other people on this site would never do that but experience tells me that there are many people who would. For me it would be interesting to have a project wizard which asked what type of project do you want to create, which namespace do you want to use for your business logic, your presentation layer and your data layer. It should ask if those components already exist and if so add the references to the project etc. Maybe even provide warnings if the amount of code within a winform or a web form is high, saying that it looks like you are mixing presentation code with business logic. It might be much and as an advanced developer you might want to switch off but it might help. What do you think ?

# April 13, 2004 9:51 AM

TrackBack said:

Visual Studio does not lead you in the direction of layering your code Insideous... [...]In other words, you create a windows form application. What does Visual Studio do, it creates a main function...
# April 15, 2004 8:02 AM

Mehran Nikoo said:

Martin, you raise a valid point. I am currently doing my research degree and my topic is pretty much the same as what you highlight.

I always use namespaces to show the layer each class belongs to. For example for example: ABCCorp.ACMEApplication.PresentationLayer. Now, assume that somebody has written a piece of code in that form, and you are reviewing the code now. If I am doing that, one of the first thing I do is to scan for SQL statements or any reference to "SqlConnection" for instance. So technically we can have an add-in or a toll that can look at the code, come back and say "Hey, this class is marked as a presentation layer class, can you please tell me what is this SqlConnection object doing here?"

I am currently half the way through the implementation and you can follow this up on my blog during June when I have some free time to write a few posts :)
# May 17, 2004 7:34 AM

TrackBack said:

# June 15, 2004 11:55 AM

TrackBack said:

# November 27, 2004 3:19 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)