design-patterns

Which way I should take to evolve in programming

Hello, There is a question which really grinds my gears. I have just recently studied the documentation "What should every programmer know" and now I am at Primer C++ 4th edition. Reading this great book which hasn't any unneeded information like starting explaining STL or MFC in the beggining. It just focuses on the language. I would l...

Is Value Object a bad pattern?

Is use of VO´s (POCO) a bad design pattern? Some people say that all domain logic of an object needs to be together in that object. Ex.: ProductVO: Id, Name, Description ProductBO: SearchById(int id), Insert(ProductVO newProduct), Update(ProductVO updatedProduct, SearchByKeyword(string word)...... ...

Should I use Areas or RenderAction in ASP.NET MVC?

I've only read a few tidbits here and there about areas so far and haven't actually used them. Same for RenderAction, but I am running into a problem where I want to separate a certain piece of the page that is being used across all pages but has it's own functionality. With webforms I'd just be using a control. With MVC I was leaning...

Multiple language components/classes [OOP/Patterns/IoC/DI]

I have several components for which there exists different versions, depending on the language used by the system (configurable, and can be changed at runtime). For example, I have an interface ("component") for Tokenizer, and two concrete implementations for english and chinese, like so: public interface Tokenizer { List<String> to...

(MVC) Controller in shared library?

In MVC, do controllers belong with an application, or can they go into a shared library? For example: //this is a shared library LibShared //these are two apps appA ->LibShared appB ->LibShared Shouldn't each app implement its own MVC and use any shared libraries as perhaps part of the app's logical model or simply another library r...

Custom ActionResults: "Not Found", "Exception Encountered" - good or bad?

Would it make sense to create the following custom ActionResults? Why or why not? NotFoundResult Currently, if an action method encounters a scenario where it needs to send a "not found" page to the user, I call this method, which is defined in my base controller class: protected ViewResult PageNotFound(string internalErrorMessage...

What is Heart Beat Design Pattern? How is it related to ASP.NET session?

What is Heart Beat Design Pattern? How is it related to ASP.NET session? ...

Question regarding custom collections in C#

I would like to know what is the best pattern when returning objects from custom collection classes. To illustrate my problem, here is an example: I have a Customer class: public class Customer { //properties //methods } Then I have a customer collection class: public class Customercollection: Collection<Customer> { public ...

Is it possible to use a Strategy pattern for data structure with no common ancestor?

I have two data structure classes (this is a simplified version of my code) Animal: Has one property “int Age” Person: Has one property “DateTime Birthday” What I am trying to accomplish is to compile “Uploading” (persisting to database), which is common across all different data structure classes. So mainly my goal is to have a s...

QT Model/View programming with complicated data structures

Greetings, I am not a professional application developer so am probably not as familiar with the model/view design pattern as I should be. Nonetheless, I am trying to use it in a hobby app and failing miserably. The primary problem I am having is that the data I am trying to display and modify is not easily represented with an extension...

Architecture for one database and several apps

If five applications are using the same database, and these apps need to be released at different times, what type of architecture or configuration accommodates that scenario? The main concern is: Any of the five applications are allowed to change the database, which can then break any of the four apps in production. ...

Aggregates and Repository. How to determine aggregates?

I have recently been looking at the Repository Pattern as a way of brushing all the details of persistence under the carpet where the client code is concerned. While reading around it appears that a Repository is/can be [usually?] responsible for aggregates rather than just straight-forward classes. This make sense to me as you could h...

How to design an UML class diagramm with non object oriented parts?

Hi, i´m coding in ABAP and implemented a template method pattern. I like to draw some UML class diagramm for this. To do this in UML for the classes is no problem. But my class is implemented in a function modul (SAP specific terms), its like an stand alone method which i use to make the implementation available to an Remote Procedure C...

Using nullable types in public APIs

I have a method in DAL like: public bool GetSomeValue(int? a, int?b, int c) { //check a Stored Proc in DB and return true or false based on values of a, b and c } In this method, I am passing two nullable types, because these values can be null (and checking them as null in DB Stored Proc). I don't want to use magic numbers, so is ...

Drawbacks of Context.Current Pattern?

For applications of any size, what are the drawbacks of using a Context.Current pattern? (i.e. "Current" is a shared/static property of a "Context" class that instantiates itself the first time it's used) Any advantage of using this pattern over just shared / static classes/methods? I'm asking in the context of .NET, although I guess i...

What are some of the best-written open-source projects you have seen?

What are some of the open source projects out there that you would hold up as shining examples of projects that correctly and effectively use enterprise sofware patterns and best practices such as Inversion of Control, Model-View-Controller, Unit Testing, etc.? For purposes of this question the project should: Include source code that...

ASP.NET MVC: enums and ViewData[] keys

For ViewData, rather than using strings as the key, I'm using enums. I currently have one big list right now that can be accessed from anywhere. Some enums are used across multiple Controller/View pairs. Is there a better way to categorize these enums rather than just an ever growing list? I don't like the hard coded strings that a...

Decorating a class whose constructor has parameters?

I am using the decorator pattern and am decorating a class with a constructor that has parameters. Below is the constructor of the class decorating; Public Sub New(ByVal repository As ISchedulingRespository) Me.repository = repository End Sub Because my decorator class inherits from the decorated class I need to declare it's co...

Are there good Patterns/Idioms for Data Translation/Transformation?

Hi, I'm sorry for the generic title of this question but I wish I was able to articulate it less generically. :-} I'd like to write a piece of software (in this case, using C++) which translates a stream of input tokens into a stream of output tokens. There are just five input tokens (lets call them 0, 1, 2, 3, 4) and each of them can ...

PHP data access design patterns to complement an ORM

I've currently got a site that depends on an Active Record pattern using the Doctrine ORM in PHP. I'm generally a fan of this approach - it's very straightforward and works well for managing for simple CRUD apps. But as this site grows, I think my need for more robust domain functionality will grow as well. I was wondering what other kin...