Thread: Code architecture: A call for advice

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    43

    Code architecture: A call for advice

    Hello everyone.

    I've been working as a programmer for some months now, and, during this time, I have been improving my programming skills a great deal. My strongest suit is implementation, meaning, when facing a problem it will be a matter of time until I find and implement a working solution.

    My weakest suit is program architecture and, for this reason, my boss proposed me a challenge in which I'll have to completely re-structure an existing program.

    This program processes information that comes from a set of sensors in order to provide important output to the main application. It is a program that runs continuously as long as the sensors are working.

    At the moment it is structured in the following way:
    Each processing unit has its own class with its own methods, variables and data. Every processing unit has an update method.
    There is a main class Process, that also has an update method that runs each time a block of data comes from the sensors. In this method I call the update of each of the processing units in the right order they need to run.

    My goal is to re-structure this architecture in order to make it more professional and create a methodology for other programmers to come and implement new features in a standard way.

    I know this was a very light explanation, but I am hoping to get some advice on how to think right when it comes to program architecture and complete my task with success.

    Best regards!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    So have you ever heard of UML for example?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Seconded. Please provide a UML diagram of the architecture. That's the first step.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    I think Salem meant the OP should study UML as a means to study and achieve better designs.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    The same. If the OP does not know UML, then the OP should learn UML.
    If that solves the OP's problem, then great, but I don't think it will. If it does not, the OP is free to check back for some advice or just conversation, but this time, with a UML diagram, or two.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by Elysia View Post
    The same. If the OP does not know UML, then the OP should learn UML.
    Incidentally, he/she should also learn functional programming. It doesn't seem obvious to me that object oriented programming would be a good choice for this particular problem.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  7. #7
    Registered User
    Join Date
    Sep 2012
    Posts
    43
    I do not know what UML is. I'll come back when I am able to provide you with those diagrams.

  8. #8
    Registered User
    Join Date
    Sep 2012
    Posts
    43
    There is a lot of material online about the UML. Is there any source you can point me that will help me to draw a simple/basic UML diagram so I can get started with this?
    I'm really interested in this tool, it seems to be very useful! It is unfortunate I had never heard of it before.

    I understand that there are 6 types of diagrams.. but is there any "abridged" version that will compact the most imporant information in only one diagram?
    Last edited by Median; 10-07-2014 at 04:04 AM.

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    There are different types of diagrams for a reason. They provide different information and putting it all into one diagram just makes it messy.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  11. #11
    Registered User Alpo's Avatar
    Join Date
    Apr 2014
    Posts
    877
    Quote Originally Posted by Median View Post
    There is a lot of material online about the UML. Is there any source you can point me that will help me to draw a simple/basic UML diagram so I can get started with this?
    I'm really interested in this tool, it seems to be very useful! It is unfortunate I had never heard of it before.

    I understand that there are 6 types of diagrams.. but is there any "abridged" version that will compact the most imporant information in only one diagram?
    I started learning with this:

    Practical UML™: A Hands-On Introduction for Developers
    WndProc = (2[b] || !(2[b])) ? SufferNobly : TakeArms;

  12. #12
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Architecture is a thought process. UML will help you represent the architecture you create. It will not create an architecture for you. You might as well try to learn about literature by studying different fonts.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  13. #13
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    The whole standard modelling process associated with UML does help think in architectural terms though. Which is an advancement over ad hoc software analysis. It also tends to force a better study of the language inheritance rules and best practices, which is essential for a good design.

    However, in all my experience, I was never been able to take full advantage of UML when coding solo. I find the process too slow and prone to constant fine-tuning, which is almost like the equivalent of the sin of over optimization in coding. The only real diagrams that I was ever been able to take advantage are ER Diagrams, and these aren't even a part of UML.

    When coding with a team and with more than one member working on code analysis, modelling under UML does seem to flow more quickly and naturally, and the implementation process does seem to occur much earlier.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  14. #14
    Registered User
    Join Date
    Sep 2012
    Posts
    43
    What I found out while I was reading about UML, is that it is a good tool to represent an existing architecture, it is not used to idealize the architecture itself. What I need is to re-structure an existing poor architecture of a real-time system that is working perfectly. The system is not too complex that a change would take too long, so I will try to idealize myself a different and better way to structure my objects.

    I will give an example. Each processing module does a specific task and has its own class. But they do not inherit from any super-class or anything.. I created them just merely as simple normal classes that are used in a "main" class. Even though these classes don't have much in common, I was thinking that it would be a nice change to make them derive from the same super-class "processingModule" or something similar.

    So you can get a clearer picture of what is in question here, what I am going to re-structure is the middle-level tracking system that handles the information that comes from a 3D sensor in order to track a user's hand and the objects on top of a counter-top. Check this video of me presenting it on IFA2014.

    https://www.youtube.com/watch?v=MjQm...ature=youtu.be

    This program has three main units. The User Interface, the Communication and the Tracking. What I am going to work on is only on the Tracking module, that performs object and finger detection and tracking. I developed that module with functionality in mind and never had the time to think about a good architecture. Now is the time
    Last edited by Median; 10-08-2014 at 10:17 AM.

  15. #15
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by Mario F. View Post
    he/she should also learn functional programming
    Yay for unhelpful, unrelated parroting of memes.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Return Code Architecture
    By juuuugroid in forum C Programming
    Replies: 4
    Last Post: 02-28-2014, 02:51 PM
  2. Replies: 6
    Last Post: 06-10-2011, 11:02 AM
  3. Sharing variables and code architecture
    By JackR in forum C++ Programming
    Replies: 2
    Last Post: 11-30-2007, 04:29 PM
  4. Need advice: catch exceptions or call methods to check bits?
    By registering in forum C++ Programming
    Replies: 1
    Last Post: 10-03-2003, 01:49 PM

Tags for this Thread