Skip to content

Design and Architecture

Discussions on Design, Patterns and Architecture

This category can be followed from the open social web via the handle design-and-architecture@forum.codeproject.com

5.3k Topics 10.4k Posts
  • OOP Programming, Two approachs for a problem

    help tutorial discussion learning
    9
    0 Votes
    9 Posts
    0 Views
    J
    How should I DECIDE if I should encapsulate all the contacts classes and methods in lets say an AddressBook class? Does the word ('AddressBook' in this case) come up often (preceded by 'the') when you talk or think about the design and how to do it? If so it's probably a good contender to be an object. Then, consider if you can come up with messages (methods) such as Set...., Get....., Do....., that you would use on this object to have it do things. Should one class contain other classes? Ask: "Does Class1 have a Class2 OR Is Class1 a type of Class2, if its the first one, Class 1 should contain Class2. Consider your: List, what happens if near the end of your coding you decide to change to, say vector or String Messages[50]. If you've written a class CMessages with methods, say, GetMessage(...) and AddMessage(..) which encapsulate this, then it's no problem. If youve used list here there and everywhere in the code it can be a real problem to change them all. a lot of inbetween methods? Being able to call Application.AddLabelToMessage(...) is probably better than needing to use four or five lines to get one object, then another from that, then another from that and finally to call, say, MsgHeader.AddLabel. You don't want to bother low level objects like, say, MsgHeader objects at a high level. Just calling AddLableToMessage hides the complication that (may) be in the method from the caller. Encapsulation is all about hiding complication. In the end, does it feel right? This may take experience but if it feels right, go for it.
  • composite pattern serializing

    csharp data-structures question regex
    2
    0 Votes
    2 Posts
    0 Views
    J
    Hi, trying to learn the GOF patterns Good thing to learn about, I finally bought the book a few months ago. trying to serialize my tree , filled with nodes I had a look into serializing a tree and I got as far as serializing the objects contained within the nodes and leaves but not the actual 'tree' information such as child/parent/leaf used to construct the tree. Which meant I could not reconstruct it. When running my (C++) program I used a Windows tree control CTreeViewCtrl to visualize the data and a third party tree container to actually hold and manipulate the data and linked the two together. I serialized the various classes that made up the objects held in the tree container using the Boost library but was not serializing the container structure. The question then arose as to should I serialize the container - which would then make the program dependant upon that container. If I did, how? This is where I left it a few months ago. my leaf objects cannot have children. Leaves cannot have children, thats correct -xml serializer cannot recognize what kind of object a child is. I used the Boost library which got round this by allowing simple additions to class code to allow each object, when serialized, to store what type of object it was - and what it inherited from. Reconstructing then created the correct objects.
  • 0 Votes
    3 Posts
    0 Views
    L
    Yeah, I guess my question is targeting the classes that might normally be created by an ORM. In our case, they are WCF data contracts, and have no behaviour. The system also has other classes with behaviour, such as a UserBusinessManager class, that exposes methods for working with a User object, to perform actions like Load, Update, Insert, etc.
  • Empty abstract method override -- good or bad design?

    design oop question
    5
    0 Votes
    5 Posts
    1 Views
    M
    :D Mark Churchill Director, Dunn & Churchill Pty Ltd Free Download: Diamond Binding: The simple, powerful, reliable, and effective data layer toolkit for Visual Studio. Entanglar: .Net game engine featuring automatic networking and powerful HLSL gfx binding.
  • UML Software

    csharp question
    7
    0 Votes
    7 Posts
    0 Views
    S
    If I need to sketch something quickly, I use Dia. It's lightweight, has most of the features I normally need, and it doesn't really matter if you're a Windows or a Linux user--you can get a build that fits either: http://live.gnome.org/Dia/Download[^]
  • Learning UML

    question learning
    3
    0 Votes
    3 Posts
    0 Views
    S
    Here's a link to an introductory article on UML: http://www.ibm.com/developerworks/rational/library/769.html[^] You can also check out the Resources section at the end of the article as well as search developerWorks for more.
  • How this can be done in Atomic way?

    database question
    11
    0 Votes
    11 Posts
    0 Views
    C
    I don't understand what you are asking. You are back after a long time! Can you be more clear about your question? CodingYoshi Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
  • Communicating the Reason for Method Failure

    testing beta-testing help
    7
    0 Votes
    7 Posts
    1 Views
    B
    I have to return something thought, and null is ideal, even if I move away from the client checking for a null return in favour of them checking a success flag or non-null error message, or one and the same.
  • A re-introduction to TDD

    testing tutorial discussion workspace
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • 0 Votes
    5 Posts
    0 Views
    B
    Jonathan Davies wrote: Possibly, if that what the User wants; which seemed a bit superflous. This is to a dictatorial application, i.e. it forces the user to do what the project owner, our management, wants. This is a utility to upgrade our main application, and the only user option is the required main application path. 'User' requirements are moot after the task of getting that location. Jonathan Davies wrote: Having worked both as a software developer and as a manager of s/w developers, what really got to me was developers investing so much time/effort in designing and producing a framework in which to execute tasks (with task interface etc) that the framework became their goa :-O Sounds like me sometimes. I used to be worse though. Thanks for your input. :rose:
  • Reverse engineering the vc++ project

    c++ design
    3
    0 Votes
    3 Posts
    0 Views
    H
    I do all my reverse engineering with Lattix (www.lattix.com), it gives you a handy dependency matrix, with which you can play and restructure your application in a nice way. It is not free, but you can download a trial that might help you out in a couple of days. It works in combo with dOxygen. If you download refer to me and they provide you some more help. Han
  • Cache Manager design problem

    help design business
    3
    0 Votes
    3 Posts
    0 Views
    S
    Now, the cache manager handles dependencies. See below: // Main delegate on which all Get requests are based on. public delegate object QueryExpression(params object[] parameters); // Main delegate on which all insert requests are based on. public delegate object InsertExpression(params object[] parameters); /// <summary> /// Summary description for CacheManager /// </summary> public class CacheManager { public TimeSpan CacheDuration { get; set; } private static object syncObject = new object(); private bool CachingEnabled = true; private bool HasKey(string Key) { return ((Object)HttpRuntime.Cache\[Key\] != null); } private Object CacheItem(string sCacheKey) { return (Object)HttpRuntime.Cache\[sCacheKey\]; } public object GetCacheItem(QueryExpression QueryExpression, params object\[\] param) { object objCacheItem = null; if (!CachingEnabled) { return objCacheItem; } if (CacheItem((string) param\[0\]) != null) { return CacheItem((string) param\[0\]); } else { lock (syncObject) { if (CacheItem((string)param\[0\]) != null) { return CacheItem((string) param\[0\]); } else { Object cacheItem = QueryExpression(param); DateTime expiration = DateTime.Now.Add(new TimeSpan (6000)); HttpContext.Current.Cache.Add((string) param\[0\], (List<string>) cacheItem, null, expiration, TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Default, null); return cacheItem; } } } } public Object InsertInCache(InsertExpression insertExpression, params object\[\] param) { System.Web.Caching.CacheDependency cacheDependency; string\[\] dependencyKey = { (string) param\[1\] }; if (HasKey((string) param\[0\])) { return CacheItem((string)(param\[0\])); } DateTime expiration = DateTime.Now.Add(new TimeSpan (6000)); cacheDependency = new System.Web.Caching.CacheDependency(null, dependencyKey); HttpContext.Current.Cache.Add((string) param\[0\], insertExpression(param), (param\[1\] == "" ? null : (cacheDependency)), expiration,
  • Exception Hierarchy

    database business oop tutorial question
    8
    0 Votes
    8 Posts
    0 Views
    C
    I don't think that anyone addressed your first question, so I'll give it a shot. In OO, encapsulation (or information hiding) concerns the way that we hide the implementation of our class behind a stable design. Thus, if I have the following class public class Person { public DateTime Birthdate { get{ ... something secret ... } } public int Age { get { ... something secret ... } } } then it doesn't matter to the code that uses the Person class if the value for Age gets computed from the Birthdate every time, caches the initial calculation in a private int, or uses some fancy Web service to calculate it. We are hiding the internals of the class implementation which, according to OO, everyone else doesn't care about. Now, in terms of the System.Exception class, it has that property InnerException because, when this is set, the instance of the Exception that you catch was created by another exception which gets stored in that InnerException property. You'll note that the only type information that we have about the InnerException is that it is of type System.Exception, no leakage at all. This does not break encapsulation because, in the context of the creation of the exception that you've caught, another exception was the cause of it and knowing that exception isn't bad. You don't know how the InnerException was set, how the value gets returned to you, or what's going on in the containing exception instance. Now, if catching code has something like the following somewhere try { ... exception thrown here ... } catch(Exception e) { if(null != e.InnerException) { if(e.InnerException is SqlException) { ... do something SqlException specific here ... } } } then I would argue that you did not handle the SqlException deeply enough in your code or that it should not have been caught until now in a separate catch(SqlException se) block. "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty
  • 0 Votes
    4 Posts
    0 Views
    J
    Storing the data produced by monitoring the file activity and processing it should be kep apart In my opinion. In this case you need a format that both Data-Storer and Data-Processor can work with, and it would seem to be wise to pick a format that can be extended easily. If you start storing data A,B and C but later realise you need D as well for each file it should be relatively easy to add. Coding any of the 'knowledge' about how processing occurrs in the Storer side would seem to be wrong. This will allow you to work on the Data-Storing code side independantly of the Processing. Presuming you store a certain set of data in this format. From this data you will produce some information, or at least rearrange the data so that it's in a format more suitable for the user or for a second stage of processing at least. This makes me think that breaking your Data-Processing down into smaller units should perhaps be woth considering. Personally I'd leave out for now how you are going to implemenet it, i.e.leave the problems of multi processes and threads until later and settle on what you are going to do first. To be able to debug this etc what about starting it all as single threaded processing file/data in serial rather than in parallel to prove that your idea of what needs to be done is correct?
  • Design question about layers and MVC

    c++ asp-net design regex architecture
    2
    0 Votes
    2 Posts
    0 Views
    J
    Seems like you have a Push or Pull quandry as examined, for example, here[^].
  • Resource Allocation Logic

    testing tools help discussion learning
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • .net Serializable DTO

    csharp data-structures help question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • bus address converter

    performance help
    4
    0 Votes
    4 Posts
    0 Views
    A
    oke,let me explain to you..i need to convert the requested memory addressto bus address.. because for a CPU to do a transaction such as I/O Read, I/o Write ,interrupt and others memory transaction, the CPU need to got through the front-side bus for it to access to requested memory in the DDR or in the Memory Controller Hub (MCH).By the way thanks for your help. i will try my best!
  • 0 Votes
    20 Posts
    0 Views
    L
    Great discussion guys. Thanks for the comments and sorry I was away for a while... this tab got lost within 40 others in my Firefox window... For now, what we wound up doing is something like this: Global.Common assembly contains base classes for Validation. Logic to load validation error message strings is different depending on what "area" of the application you are calling validation from, ie. UI vs. BLL Each of our "areas" also has an assembly for common code (shared among the assemblies in that area) so we have: UI.Common and BLL.Common For the validation example... we created a validation class in UI.Common that inherits from Global.Common, but provides its own implementation that loads the message strings from our BLL by calling through WCF. We will create another validation class in the BLL.Common that inherits from Global.Common, but this implementation will call the BLL methods directly to load the message strings, without going through WCF. This way, the cross-cutting concerns are kept within the 3 Common assemblies and uses a provider model idea for the loading of message resources.
  • 0 Votes
    1 Posts
    0 Views
    No one has replied