Click here to Skip to main content
15,917,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written a program using OO and found that its not as versatile as I would like. Changes are difficult as there are a lot of dependencies. So I have decided to re-write the program and in doing so, I have been doing some research into current practices. I see new things like factory methods, dependency injection, inheritance, extension, implementation and interfaces.

There are lots of examples online for each of the patterns I mentioned but what I need is a template, outlining how they should be used in conjunction with each other. My program will need to use listeners and shared resources such as Lists. I have found trouble in learning how I should structure my program around a shared resource.

Can anyone point me to a basic template for structured programming, demonstrating how these sorts of patterns, should be used in conjunction with each other?

Thank you in advance and I hope I didn't just sound too dumb. XD...

What I have tried:

I searched the internet and also posted on StackOverflow which got me banned for not asking the correct way.
Posted
Updated 7-May-16 0:26am
Comments
Sergey Alexandrovich Kryukov 7-May-16 11:36am    
I'm just curious: did then simply remove your question at StackOverflow, or really banned your account?
Here, your question can also be removed for abuse, but you hardly can get even a abuse report on your account, which happens only due to some unethical or disruptive/rude behavior.

Your question is not very productive, but your concerns are quite reasonable. Your whole idea is wrong though: engineering is not done according to templates. And even design patterns should not become a Procrustean bed. You should come from understanding of your project's goal, and important one is its maintainability.

—SA
Michael Hurt 8-May-16 9:02am    
Hi and thanks for replying. It was actually a difficult question to structure for a site such as StackOverflow as it is very ambiguous. How do you ask for something your not even sure exists? The short version is that the community there has become very intolerant and rather than helping me to improve my question, they just spammed it with a stack of down votes. This had an extremely negative impact on my reputation leaving me banned from asking further questions. In addition to the down votes, there were also a lot of negative comments which left me reluctant to post there in future.

Of course you are correct, no-one can design a template to suit a program I haven't even written yet. What I was looking for is a basic outline of a simple program which employs a range of different patterns. My hope was that it could provide some insight into which patterns are best suited to which types of situations. I just don't want to find myself beginning a section of program using the wrong type of pattern and having to re-write it.

I quickly came to realize that what I am searching for doesn't exist and so I wrote an article to help others who may have similar issues.

http://www.codeproject.com/Articles/1098482/Structured-Programing

At the moment im personally stuck on how to turn a switch case statement into a dictionary using custom IOC. Each case in the list invokes a method so I tried to load up a hashmap of the case with the method, however as soon as the compiler see's the assignment 'action.put("command", myCommand(args, user);', it immediately executes the method. And so you can see why im looking for such examples of how and where such patterns are appropriate and how others have implemented them.
Sergey Alexandrovich Kryukov 8-May-16 9:27am    
Well, I'm afraid to say, I see very little value in this article. In brief, it's way too eclectic. Why emphasizing some expect and neglecting others (even if you cannot cover all aspects). It's just a set of claims, without any reasoning. Some items are questionable, some are commonly understood incorrectly, so it would be good to clarify or offer alternative view on them. Most importantly, the creative part of the development is neglected; the article maintains the common illusion "follow cookbook recipes and the work will be done". And, most importantly, the article itself, as far as I can see, lacks original conception.
—SA
Michael Hurt 8-May-16 10:28am    
You are correct, I did try to keep it brief and give a general overview so as not to overload new programmers with too much information. My intention was to provide a brief introduction to some of the most important concepts, not to give an in depth lecture on each of the individual concepts. My alternate objective was to help them avoid some of the common road blocks along the way.

If you do believe that I have overlooked a concept that is extremely important, or that a section warrants reference materials or refinement. I would be all to happy to discuss any changed you might suggest.
Sergey Alexandrovich Kryukov 8-May-16 11:16am    
Thank you for understanding. I doubt it's very fruitful topic for an article, in general. It's good that you can motivate your point, but my note on each would be: "what's the value of it, from the publication standpoint?"

(One more problem: some of the items you mentioned intersect or covered by one or more S.O.L.I.D. principles, which are well-known, but you fail to reference them. In influential peer-reviewed scientific journals such lack of referenced would be more then enough to turn down the submitted publication.)

I would rather advice to pay attention to every technique you devise or use, from the standpoint of maintainability, readability, flexibility, preserving the value of the code as an assert, and so on. Then you can come to some separate cases, positive or even negative, which might be interesting enough to make it as a pattern or anti-pattern. Then it would be interesting for the readers. The article should make some of the reader thinking "hm… but this is an idea I would like to try". Even if you have only one point, it can be good enough for the article.

I would really advice to leave all kinds of itemized sets of advice and similar reviews to your own records. I understand that it sounds discouraging, but this is what I think.

One special concern is design patterns. You article lack criticism of them. If you don't have anything against them, you still need to refer to well-known criticism of the idea to use them. I'm one of the people criticizing not particular patterns (some deserve separate criticism, some are very good), but the idea of using them the way many take. I'm even tend to come to the conclusion that, effectively, many pattens, good by themselves, contributed to the present sorrowful state of software development in many teams. Sometime, it looks like disaster. People tend to think that using the patterns is either their obligation or virtue. The try to stick their code in Procrustean bed of some patterns, wasting time, cluttering valuable code, forgetting the real goals of their product. As if their goal was pleasing the author of one or another pattern. I saw one project which I had to fix, where the authors tried to stick in probably all patterns they learned, which actually resulted in using nearly all well-known anti-patterns. I would say, the biggest anti-pattern was using those patterns. And you did not even mention a single anti-pattern...

—SA

1 solution

There is no simple answer, or template, for such a question. Program design is an iterative process, starting with the basic business problem details, and progressing to the detailed requirements, design and code. The use of patterns such as you mention above will only become obvious as your design progresses, and you may find you need some, all or none of them in your final product. Further reading of design papers and tutorials may help you to make decisions along the way.
 
Share this answer
 

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