design

Java - Design advice for simple game

Hey, I'm implementing a simple "Play your cards right" (otherwise known as higher/lower) game. In case you've not come across it before the rules are really simple. A single suit of cards (e.g. hearts) are used. One card is drawn at a time and the objective is to correctly guess if the face value of the next card will be higher or lower...

What kind of object tree is this?

I need to create a tree, constructed of nodes that may have any number (within reason, between 0 and 10 say) of outgoing transitions, like so: X / | \ X X X / X / \ X X What sort of tree structure is this? What techniques are there for constructing and ...

Singleton Models Doctrine

Can we have a model class which is singleton in Doctrine? For Singleton classes I should have a private/protected constructor....but this is not possible as I am extending a Doctrine class which has a public constructor You can argue about the use of the Singleton pattern when interacting with the DB, but just consider this scenario: ...

What are the best reasons to avoid Javascript popups on a website?

I'd would like to know all the reasons to avoid popups in a website (in a web design best practices point of view). Ex : doesn't use all screen space, needs Javascript... ...

wireit: visualizing a directed graph with nodes that can contain nested graphs

Problem: There appear to be many tools for visualizing graph structures, but none of the ones I've seen so far seem to have the feature of "nesting". The WireIt library (apparently inspired by Yahoo Pipes) looks very promising, but it seems to lack this concept of nesting. To explain what I am thinking of, consider a Company Org Chart ...

Cocoa Callback Design : Best Practice

I am writing the middleware for a cocoa application, and am debating over how exactly to design callbacks for many long running processes. When the UI will call a function which executes for a long time, it needs to provide a delegate to allow at least: Report of Success (with return value) Report of Failure (with error value) Report ...

Looking to replicate this idea

Just bumped in to this great implementation on click expand http://www.timstravelog.com/lifelist/ I want to implement something similar for my own lifelist. Any recommendation on how to go about it? Is this jquery? I am a noob of shorts, so please excuse my ignorance ...

MVC in Android: Application or Service for asynchronous updates?

(I'm sorry for not being so clear in my first post) Here is the situation: I have data that is to be refreshed from the Internet. Let's call it Model. What I want to do: Basically it sounds like an MVC model, where the Model is also kept persistent in local (private) storage. The Model and its associated methods are application-wise. T...

Design of caching for a medium/small web app?

I have a web app that's currently ~700 LOC in JS (more is serverside). I'm using jQuery. As I find myself trying to minimize AJAX requests to the server, I've got an awkward mix of caching and spaghetti code developing. It feels like I need a more centralized solution. My idea: Create a map with the AJAX call to make (URL and args), and...

Could this be a good use of global variables?

Global state is conventionally frowned upon. However, I think I can use it clientside to make my app simpler. I have an AJAX web app that sets up several values when the user logs in - user id, as well as some other information. This info does not change for the lifetime of the app. I also have a cache of data to minimize trips to the...

Useful Vim plugins for web development and design (php, html, css, javascript)?

Right now I'm using surround.vim to enclose text in HTML tags, and a plugin that highlights text according to the hex value in the CSS file (e.g. #888 will have gray background in the CSS file). Are there other useful plugins for web development? Recommendations Here is a list of the plugins mentioned in the answers so far: surround...

I was unable to centered a text on left side

<table> <tr> <td class="left"><div class="c">centrated<br>on<br>lef side</div></td> <td>middle-td</td> <td>right-td</td> </tr> </table> Here is the css: td.left { width: 200px; left-padding: 0; } div.c { text-align: center; } Now everything is centered. I want to place the div on left side and everything inside t...

Design of class creation. Need some help

Hello, guys! I have some code: public class class1 { public class1(int count) { // count must be 4,6,8 } } That class 'class1' is a public class in my SDk library which I write. Count variable is a very important for class1. It must be either 4,6,8. I want to ensure that programmer (used my SDK) can't create an ...

How to create a correct hierarchy of objects in C++

Hi, I'm building an hierarchy of objects that wrap primitive types, e.g integers, booleans, floats etc, as well as container types like vectors, maps and sets. I'm trying to (be able to) build an arbitrary hierarchy of objects, and be able to set/get their values with ease. This hierarchy will be passed to another class (not mentioned ...

Critique this c++ code.

Similar to the code written below exists in production. Could you people review it and tell me if such code works well all the time. class Base { public: virtual void process() = 0; }; class ProductA : public Base { public: void process() { // some implementation. doSomething(); } void ...

Drag and drop overlapping ImageView in Android

Hello all, I have a table-top style game board consisting of 10x10 squares. Each square is a PNG image. On top of these squares I want to place tiles which can be drag and dropped on top of the squares. What would be my best approach concerning Views? Is it possible to have two layers where layer one is a grid of ImageView's which rep...

Python: **kargs instead of overloading?

Hi, I have a conceptual Python design dilemma. Say I have a City class, which represents a city in the database. The City object can be initialized in two ways: An integer (actually, an ID of an existing city in a database) A list of properties (name, country, population, ...), which will generate a new city in the database, and re...

Should I return an IEnumerable or IList?

I wish to return an ordered list of items from a method. Should my return type be IEnumerable or IList? ...

More on the mediator pattern and OO design

So, I've come back to ask, once more, a patterns-related question. This may be too generic to answer, but my problem is this (I am programming and applying concepts that I learn as I go along): I have several structures within structures (note, I'm using the word structure in the general sense, not in the strict C struct sense (whoa, w...

Why does a button event function run during a page reload in ASP.NET ?

public partial class Stats : System.Web.UI.Page { public SqlDataReader DataReader; public SqlCommand Command; string queryString = ("INSERT INTO UserData (UserProfileID, ConfidenceLevel, LoveLevel, HappinessLevel) VALUES ('a051fc1b-4f51-485b-a07d-0f378528974e', 1, 1, 1);"); protected void Page_Load(object sender, Event...