design patterns - Naming Classes - How to avoid calling everything a "<WhatEver>Manager"?

A long time ago I have read an article (I believe a blog entry) which put me on the "right" track on naming objects: Be very very scrupulous about naming things in your program.For example if my application was (as a typical business app) handling users, companies and addresses I'd have a User, a Company and an Address domain class - and probably somewhere a UserManager, a CompanyManager and an AddressManager would pop up that handles those things.So can you tell what those UserManager, CompanyManager and AddressManager do? No, because Manager ...Read more

conditional - What pattern or principle to use, in order to simplify generation of content that is based on lot of parameters?

In a situation, where you need to generate a bunch of <title>, <meta name="description"> and <h1> tag contents, based on many query search parameters for thousands of pages. What principle or pattern is best fit in a situation like that?For example:You will get some array with lot's of query parameters, like the type of some object, it's features, location and many more. Based on the parameters, you need to generate, translate and render, different content in tags. What to do to avoid too many if statements and switch cases.I ...Read more

design patterns - Best way to implement HUD. - Cocos2D

Hello my fellow coders.I was developing a game, but I came across a small problem.What could be the best way to implement a HUD? Im talking design here, not the actual way of creating one.For example.You've got :GamePlayScene-Inside the Scene you've got:-BackgroundLayer-GamePlayLayerSo, where would you add the HUD?What do you think would be more manageable?Would you do an extra layer or just add it on gameplay?If I chose to add an extra Layer, what could be the best way to communicate between layers?Background does the game "map"(If you would l...Read more

design patterns - What is so bad about singletons?

The singleton pattern is a fully paid up member of the GoF's patterns book, but it lately seems rather orphaned by the developer world. I still use quite a lot of singletons, especially for factory classes, and while you have to be a bit careful about multithreading issues (like any class actually), I fail to see why they are so awful.Stack Overflow especially seems to assume that everyone agrees that Singletons are evil. Why?Please support your answers with "facts, references, or specific expertise"...Read more

nlp - How to tokenize Spanish text with NLTK or Pattern-es

Basically the issue I am having is with separating object and direct object pronouns from verbs.Ie 'aprenderlo' should ideally be tokenized as two separate entities, 'dimelo' should be tokenized as three. I have tried a variety of taggers in both libraries, and so far nothing has produced the results I want. However, I am sure this must be a common problem - any ideas?...Read more

repository pattern variations?

Based on the following url, a repository pattern is basically a layer of repository objects that are used to encapsulate data access: example, a UserRepository object would have a GetUsers() method like thispublic User GetUsers(){ return context.Users;}Is that all there is to the Repository pattern or is there more to it? Are there any named variations of this pattern? For example, I think I encountered someone in the past who asserted that this pattern involved generic/dynamic CRUD for e...Read more

SVG pattern: relative coordinates using viewbox. issue in firefox

I have a problem with a pattern that has to have relative coordinates in my SVG. At first, I used patternContentUnits = "objectBoundingBox" which seem to work well all modern browsers. However, I wanted use Batik Rasterizer to allow users to convert SVGs to PDF and/or PNG and Batik Rasterizer doesn't seem to support patternContentUnits = "objectBoundingBox for SVG to PDF conversion.<pattern id="Pattern2" x="0" y="0" width="1" height="1" patternContentUnits="objectBoundingBox"><rect x="0.1" y="0" width="0.33" height="1" style="fill:rgb(...Read more

design patterns - How to structure complex "state updating functions" in Clojure?

I have a game state represented as a map and some logic that updates that state on every game 'tic'. But I can't figure out how to structure the update function in any sane way.What is the idiomatic pattern for structuring functions like this?Here is some pseudo code for what I want to do:(defn tic [g] "Return an updated game" g1 = (update-in g [:day] inc) g2 = (if (some-cond) (some-update-func g1) g1) g3 = (update-in g2 [:fu] fu-update) ... many more ... g-last)I don't really care about the intermediate states, but using the -> macro does...Read more

Pattern/idiom for functional state updates in Clojure

I've decided to try and write a simulation program in Clojure (as a proof of concept) where:The entire state of the simulation is stored in a single immutable data structureState updates are represented as functions that map a state to the next stateThis means that I could write an update function as something like:(defn example-update-function [old-state] (let [state (atom old-state)] (swap! state some-other-update-function-1) (if (some-condition @state) (swap! state some-conditional-update-function)) (swap! state some-other-upd...Read more