Patterns and my program

Posted on 2008-11-20
Last Modified: 2013-11-11
Hi there,

I am working on a project and am learning VB.NET at the same time. I decided to do a simple accounting system.

The first thing I did was to create a form that would load clients. Double click on a client and you could edit the client. Basic information for the client like name address etc. A client might be a particluar type eg company or private - difference would be a tax number.

I also have a form that shows all the accounts in the chart of accounts.

Each form has code behind it but I have completely separated all the code and moved it to a helper class. So all thats in the form code is the event handlers and a function call to the helper class.

So two classes for each form. The client is completely self contained. All I require out of this is a client number. I used LINQ to obtain all the clients.

MY QUESTIONS: I have been reading about patterns. Given I select a client and an account for a journal... is there a pattern that I might follow?

Is creating a helper class for each form a good way to go given that there is some reused code?

Question by:si2030
    LVL 6

    Accepted Solution

    Since you have event handlers in .NET, you get to avoid a lot of the behavioral patterns that tend to show up frequently in GUI applications.  When starting out with design patterns, be careful not to create classes just because it can.  Using design patterns will help you maintaining and extending an application.  If you want to add functionality, you can add them without modifying code everywhere.

    The obvious application of design patterns here is the abstract factory pattern in the definition of your client.  All the common code between every type of client in the system go in the abstract class.  This includes public and private (maybe common LINQ queries).  Anything specific to a company/private client will go in their respective classes.

    An example could be a method that applies interest to all client accounts, assuming a different interest rate is used for a private and a company account.  A virtual applyInterest method in the abstract class will allow you to calculate the new balance (held in a protected member variable in the abstract class).

    My point is that most of the functionality that your after can be contained in this type of an abstraction.  Designing separate classes for each form isn't necessary if they don't contain state.  You right in trying to abstract out common functionality between actions, but I think that pulling all the logic out of every form isn't necessary.

    As general advise, try to abstract out parts of your code that can represent a real object, and create a hierarchy.  After you realize what objects your system will use, use necessary design patterns to define the ways they will communicate with each other.

    Author Closing Comment

    I have been thinking on this alot. In this project the only thing that the rest of the program will ever see or want regarding the client is the client number. The form that displays clients is fully self contained and has no other functionality except to add new clients or edit... or select. This section of the project could be used as a block in other projects that need to select the client. I can see where your suggestion comes to the fore where I might have it working for tax in one application and no tax in another...

    Thanks for the direction


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Software development teams often use in-memory caches to improve performance. They want to speed up access to, or reduce load on, a backing store (database, file system, etc.) by keeping some or all of the data in memory.   You should implement a …
    Dependencies in Software Design In software development, the idea of dependencies ( is an issue of some importance. This article seeks to explain what dependencies are and where they …
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video discusses moving either the default database or any database to a new volume.

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now