Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to bridge a mental gap between the OOP principle of Layered Architecture[^] with the way that VS.NET starts a windows forms application. After designing my initial form I double click and get this code:
Public Class frmMain
    Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'code here'
    End Sub
    'other subs etc'
End Class

This does not give me a good way to set up all of my Layers since the only way to do so would mean putting "business layer" code into frmMain_Load() which is a User Interface Layer. In this blog: http://oopstruggles.blogspot.com/2008/10/oop-architecture.html[^] Tim gives an example of what I think this should look like with: class RealLife way down towards the bottom of his example.

I can think of a way to do this with a modMain module which contains a Public Sub Main() routine. This would be called by frmMain_Load(...)... in the main form when the application loads. But this all seems like I'm adding a band-aid to the way that VS.NET implements its solutions.

Am I using objects wrong if I need a facilitation sub like Tim is talking about? How should I set up my object facilitation code if that is the correct use of OOP Layers in VS.NET?
Posted
Comments
Sergey Alexandrovich Kryukov 11-Feb-13 23:45pm    
What is VS.NET Form application? :-) No, there is no such a beast.
What do you mean by administration of the application?!
What are "OOP layers"?

As I can see, you are asking about something which is nothing but a fruit of your own (or someone's) fantasy, not anything real...
—SA
Turbonate 11-Feb-13 23:51pm    
In Visual Studio 2012 if you click new > Project the very first option is "Windows Forms Application". This response makes me think you just answered without reading the post.

If you read into layers in OOP you'll know that there's a user layer, business layer and data layer which are supposed to be kept separate for best practices. It's all in the link that I posted in my first sentence.

It's not a fruit of my fantasy, thanks for the encouragement.
Sergey Alexandrovich Kryukov 11-Feb-13 23:58pm    
Maybe I'm just dumb; I read two times. :-)
I know what are layers, but why you call them "OOP layers"? Other things?
—SA
Turbonate 12-Feb-13 0:04am    
ok, I call them OOP Layers because they're listed in section 4.29 and 4.30 in the link titled: "Introduction to Object Oriented Programming Concepts (OOP) and More".

I'm trying to figure out how to separate my business layer from the forms layer (from an architectural standpoint) without relying on the user interface layer to start the application. I know what will work, but I'm more interested in the correct way to do this because procedural code "works", but it's a mess to work with.

I use the phrase administration because that's what I can think to call my application start-up sequence. I have to initialize all of my objects somehow, it just seems wrong to do that from a form.
Sergey Alexandrovich Kryukov 12-Feb-13 0:09am    
I see. This article is too shallow to consider it seriously. Read on major design patterns in, say, Wikipedia, and you will see how layers work. MVC, MVP, MVA and MVVM.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900