Relative Content

Tag Archive for design

Limitations of Polymorphism in statically typed languages

I program mostly in statically typed languages, like C++ and Java. A common strategy employed in languages like these to handle dealing with collections of objects which are related, but which need to employ specific behaviors, is to use polymorphism and inheritance hierarchies. But Polymorphism only works when the Base class has a method (virtual function) which can then be overridden by every Derived class. But there are often cases where a Derived class needs to have a method, and it doesn’t make sense to place a method of the same name in the Base class, because it is very specific to the Derived class.

Python simulation-scripts architecture

Situation:
I’ve some scripts that simulate user-activity on desktop. Therefore I’ve defined a few cases (workflows) and implemented them in Python. I’ve also written some classes for interacting with the users’ software (e.g. web browser etc.).

Which programming designs leads to more problems?

As a fresh programmer, one of the first thing for me to learn was to learn language and its syntax. Now my next training issue is to design my code heirarchy in such a way it is simple to maintain over time. One example I just encountered is below. It is in VBA for Excel but the concept extends to other languages too.

Pass ID or Object?

When providing a business logic method to get a domain entity, should the parameter accept an object or an ID? For example, should we do this:

How to implement a simulation pattern for a repository?

Let’s say I have a repository of functions. These functions work with business objects within a database, CMS or other third party API. For example, my repository interacts with virtual files and documents in a document management system. I want to be able to implement a simulation mode in my repository such that when I execute commands, I want to see the result of it without it actually doing anything. This is to reduce the risk of someone executing a series of commands in my repository and doing something dangerous. I want them to first see the output and confirm before executing.

How do you organize highly customized software?

I’m working on a large software project which is highly customized for various customers arround the world. This means that we have maybe 80% code which is common between the various customers, but also a lot of code which has to change from one customer to the other. In the past we did our development in separate repositories (SVN) and when a new project started (we have few, but large customers) created another repository based on whatever past project has the best code basis for our needs. This has worked in the past, but we ran into several problems: