pattern

Should I separate data from Facade Class?

I'm making a "back-end" engine of HomeCAD. I have a facade class that do many things. But should I separate data (like array of object) from that class? Many thanks ...

Is it breaking Facade design pattern

In HomeCADEngine facade class I have a method "addRoom(room:Room)" and it will add this room to a ArrayList. But is it break facade pattern when we create a room outside facade class and then pass it into addRom() method?? Many thanks ...

Data Mapper API - unsure about organisation

Let's say we have "User" and a "Hotel" model classes. I'd use a User_Mapper and Hotel_Mapper to load/save/delete etc. I want to then have the user be able to mark their "favourite" hotels. In the database I have my user_favourite_hotels table which is a simple link table along with say a field for subscribing to hotel updates. When list...

Best way to manage things like bullets in a game?

I've been starting to get into game development; I've done some tutorials and read lots of articles but one thing I'm not sure about is what is the best way to manage large numbers of temporary objects, e.g. bullets. Should each entity manage its own bullets, should I have a global bullet manager or should I create each bullet as a new ...

[Haskell] Pattern Matching and Recursion

I am new to both Haskell and programming. My question about binding in pattern-matched, recursive functions. For instance, suppose I have a function which checks whether a given list (x:xs) is a sublist of another list, (y:ys). My initial thought, following the examples in my textbook, was: sublist [] ys = True sublist xs [] = False sub...

Generic (non-file) pattern matching in Makefile

Is it possible to have wildcard targets for non-filenames, like: build-%: pull-% build-%.stamp pull-%: cd $* ; git log HEAD..origin/master | grep -q . && ( git pull ; $(RM) ../build-$*.stamp ) || true build-%.stamp: cd $* ; ant touch $@ The idea is to call make build-foo, which will only call the build when there are new upstrea...

function to return index of largest neighbor

F# function Problem: given a list of items e.g.: ["5";"10";"2";"53";"4"] and a Search Index, I require a function such that it compares the current given index against its neighbor, returning the largest index Example: Given Index 1 will return Index value 2 (because 10 is greater than 5). Given Index 4 will return Index 4 (beca...

what's design pattern principle in the Android development?

I was a JaveEE developer. Recently I joined an Android development team. The structure of Android confused me. The MVC design pattern seems not suit for Android development. So what's is the design pattern principle for Android development? I means is there any hint about how to write a clean, easy reading and effective Android code. ...

Howto load different libraries based on incoming paramters?

Hello, I am creating a java client using different libraries, they are the same base, but with different optimizations. Is there a pattern (or something else) that I can use to load different libraries, e.g.: java -jar myapp.jar 1 (loads with libraries from set 1 and imports correct and creates a client using this library).... Update...

"ASP.NET Webforms MVP" as an alternative to "ASP.NET MVC"

Some days ago I discovered a "thing" which is called the ASP.NET MVP framework ( http://webformsmvp.com/ ) What do you think of that ? Is it worth to take a look on it ? Has anybody already experiences with that ? I come from the "webform side" (and also from the desktop development) and really don't want to move to ASP.NET MVC for th...

Android Content Provider inside the same application

I've more than one activity (inside the same Application) that needs to have access to the database. What's the best pattern to implement this ? Do I need a content provider even if all activities belong to the same application? Which activity should have the responsibility for opening and closing the database ? ...

Why use the command pattern in GWT (or any web app)?

According to this video here Google is recommending the use of the command pattern on top of its request handling API. There is also a helpful looking project gwt-dispatch that implements that pattern. According to gwt-dispatch documentation I need to create four classes for each command: an action (e.g. command) a result (e.g. respo...

Is the adapter pattern usable in cases where the different interface methods have varying parameters

I am creating a client side swing app that will have data provided by/from one of many data providers(brokers). The data providers however, have varying ways of perfoming same things e.g. broker1's login method public boolean doLogin(String username, String password); broker2's login method public int login(String username, String p...

Setting android unlock pattern from code

I'm making an application that locks the phone down after some event. Basically it just turns off the screen and the android lock screen activates. I've set the LOCK_PATTERN_ENABLED setting in order to make sure that the lock pattern is visible when the user has to unlock the device. The problem is if the user had the lock pattern turne...

Aspect Oriented Development/Programming resource

Recently, I've had a request to implement logging for all of the Controller classes in my ASP.NET project. I've used postsharp and everything is working great! But, usual question: is there any OpenSource component or any pattern? Also, I want to know more about AOP design patterns, resources and real-world application. ...

Unit test method with mock DAL, but underlying method calls different (real) DAL

I'm trying to implement unit tests in my current project. After that I'll start developing using TDD further on in this project. Yesterday I started making some tests and it wasn't as easy as it looks in theory/books. At the moment I'm struggling with a specific scenario, which I know someone else must have worked with in the past also....

Rendering and editing complex business object

I have a business object representing an invoice with all its line items, contractor data, bank account number, etc. I want to be able to display such an invoice and allow user to edit it, for instance to add new line item or delete an exisiting one. User should see all properties of an invoice. What's the best way about it? Should I...

How to memset() memory to a certain pattern instead of a single byte?

I am facing today with a problem where I need to change memory to a certain pattern like 0x11223344, so that the whole memory looks like (in hex): 1122334411223344112233441122334411223344112233441122334411223344... I can't figure out how to do it with memset() because it takes only a single byte, not 4 bytes. Any ideas? Thanks, Boda...

Design patterns to reduce coupling in Swing application

Hey all, I'm currently working on a Java Swing application and I was looking for some guidence. The application is fairly small, but I'm noticing that as the code base is growing larger, that I have an awful lot of coupling in my object graph. I'm relatively new to Swing, but I've been programming long enough to know where this is headed...

how to iterate all array element starting from a random index.

I was wondering if is it possible to iterate trough all arrays elements starting from any of its elements without pre-sorting the array. just to be clearer suppose i have the array of 5 elements: 0 1 2 3 4 i want to read all elements starting from one of their index like: 2 3 4 0 1 or 4 0 1 2 3 the idea is to keep the element orde...