I have code that when given a thing it needs to sort out what specific kind of thing it is and then take special actions based on that. The possible classes it could be are all desc
public void doSomething(BaseThing genericThing)
{
if (genericThing instanceof SpecificThing)
{
SpecificThingProcessor stp = new SpecificThingProces...
I know this is likely to be an open-ended kind of question, but I'll take the best-regarded answers and consolidate them here for reference.
I'm working on a set of tools to read and write Mobipocket files (a.k.a. Kindle eBooks) using C#, and am running into a design question when it comes to writing new files. The underlying file form...
from http://www.php.net/manual/en/class.pdo.php
###### config.ini ######
db_driver=mysql
db_user=root
db_password=924892xp
[dsn]
host=localhost
port=3306
dbname=localhost
[db_options]
PDO::MYSQL_ATTR_INIT_COMMAND=set names utf8
[db_attributes]
ATTR_ERRMODE=ERRMODE_EXCEPTION
############
<?php class Database {
private static $lin...
from http://www.php.net/manual/en/class.pdo.php
###### config.ini ######
db_driver=mysql
db_user=root
db_password=924892xp
[dsn]
host=localhost
port=3306
dbname=localhost
[db_options]
PDO::MYSQL_ATTR_INIT_COMMAND=set names utf8
[db_attributes]
ATTR_ERRMODE=ERRMODE_EXCEPTION
############
<?php class Database {
private static $lin...
So I've found a method which looked nice to me: http://www.php.net/manual/en/class.pdo.php#97682
Requires PHP 5.3 but my host only supports 5.2 :(
So what method should I use for PDO, where it only connects to the database when needed?
And reuses the same connection?
...
Hi everyone,
I have a dilemna that needs I've been thinking a while but still haven't figured it out how to effectively and efficiently code (design) it.
I have object data that get returns in 3 text-based formats: JSON, XML, ATOM. In JSON, the data can be a JSON Object or JSON array. XML and ATOM are xml.
Based on these 3 formats, I ...
I am rewriting a client's application from a crappy built as one huge blob of a project into a MVC application for obvious reasons.
In doing a view for pieces of it I am noticing the original programmer has plenty of statements where they change up images or put in different links based on the logged in user.
How does everybody that wr...
I have a composite object that was generated from an xml schema that I need to populate with data from a database.
The generated code doesn't enforce the schema's rules regarding required elements, max occurances, etc. I'd like to create a class (or collection of classes) to help fill in the composite object and ensure when its serializ...
I'm writing an application where users can create one or more "Catalogs" which are stored in a database. However, I want to allow for multiple database formats (SQL Server and SQL Lite), and I want a user to be able to have multiple catalogs opened in the application simultaneously. The location of the catalog databases will not be know...
What object oriented design patterns do you use in your application's javascript, and why?
Feel free to post code, even if there is no formal design pattern attached to it.
I have written plenty of javascript, but I have not applied much object orientated patterns to what I am doing, and I am sure i am missing a lot.
...
I have a Java main application with somewhat complex command line arguments. These arguments are currently processed by a CommandLineArgumentProcessor class. Here's what my code current looks like:
public static void main(String[] args) {
Injector injector = Guice.createInjector(new ConfigModule(), new WorkModule(), new ReportModul...
This is a question about style and design rather than syntax.
I have domain models that have several (for lack of a better term) navigation properties. So in my strongly typed details view of Foo which has a property of type Bar I could do the following:
<%: Foo.Bar.Name %>
However, sometimes Bar is Null, so I end up with something ...
I have an interface called IProjectUser that defines a read function and a write function for reading and writing to project files. I also have a class called Project that holds a generic list of IProjectUser objects to manage project files. Both of these are in the class library Project.dll.
I also have a class library called A.dll tha...
I have a class that I am using all over the place in my code. It contains settings and other core functionality. Here's what I'm doing right now to use the class.
$settings = new Settings();
$settings->loadSettings();
Then, when I need to the code in some random function in another class, I do something like this:
function abc() {
...
I've got a solution (.net 4, c#) consisting of a webapplication, several windows forms apps and a couple of windows services. Now I'd like to implement a global caching mechanism, so that all these application access the same cache (if possible with as little changes to existing code). My first guess would be using a AOP for implementing...
What should go into a class declaration in C++?
For example, I have the following in a header file:
class BoardState {
public:
BoardState();
bool HasWon() const;
bool HasMoves() const;
bool MakeMove(const int column);
bool UndoMove(const int column);
const Chip (&grid() const)[kGridHeight][kGridWidth] { return grid_; }
...
I am going to be implementing a network protocol (specifically, SFTP) and I wondered if there are any general rules-of-thumb to follow?
At the moment it seems like a mammoth task and I'm at a loss as where to start.
I'm looking for:
Tips
Best practices
Possible design patterns
Experiences
Try to keep it applicable to network protoc...
Hey Stack Overflow'ers,
I'm stuck in a C# program I'm developing, and I think it's because I am taking the wrong approach.
You see, I have these settings in an XML file, which are read at runtime. For each setting, I want to create a new object that does stuff.
I think I can do that, but the problem is, how do I reference those obj...
Hi Guys, I been researching for weeks about this.. I'm currently designing a loosely-coupled architecture design using n-tier(3 layered) method and factory design approach. My goal is to put each Client's business logic (ClientA.DLL, ClientB.DLL) in separate namespaces so that the project scales out meaning I can modify/remove/add a spec...
I'm working with Doctrine2 for the first time, but I think this question is generic enough to not be dependent on a specific ORM.
Should the entities in a Data Mapper pattern be aware - and use - the Mapper?
I have a few specific examples, but they all seem to boil down to the same general question.
If I'm dealing with data from an ...