I have a circular dependency in my code, and I'm not sure how to resolve it.
I am developing a game. A NPC has three components, responsible for thinking, sensing, and acting. These components need access to the NPC controller to get access to its model, but the controller needs these components to do anything. Thus, both take each oth...
Hi,
Is sequential coupling really a bad thing in code?
Although it's an anti-pattern, the only risk I see is calling methods in the wrong order but documentation of an API/class library with this anti-pattern should take care of that. What other problems are there from code which is sequential? Also, this pattern could easily be fixed...
If you take a look at http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/activedirectoryoperations11132009113015AM/activedirectoryoperations.aspx, there is a huge list of properties for AD in one class.
What is a good way to refactor such a large list of (Related) fields? Would making seperate classes be adequate or is there a bette...
I want to be clear on this. When I say domain anaemia, I mean intentional domain anaemia, not accidental. In a world where most of our business logic is hidden away behind a bunch of services, is a full domain model really necessary?
This is the question I've had to ask myself recently since working on a project where the "domain" mod...
It doesn't seem that this exact question has been asked before, so I'll fire away:
Most of us are familiar with the concept of an anti-pattern. However, avoiding implementation of anti-patterns can in principle swing too far the other way and cause problems itself. As an example, "Design by Committee" has a counter-example that I'd call...
Hi guys
I'm just starting a project which requires some pretty hardcore linq to xml to be used and I am just wondering what people consider best practice and lessons learnt.
For instance, I am worried about all the nulls that are possible all over the place... This is something that I am using but how do other people deal with it:
...
I'm currently developing a component based API that is heavily stateful. The top level components implement around a dozen interfaces each.
The stock top-level components therefore sit ontop of a stack of Abstract implementations which in turn contain multiple mixin implementations and implement multiple mixin interfaces.
So far, so go...
Lets say that I have a library which runs 24x7 on certain machines. Even if the code is rock solid, a hardware fault can sooner or later trigger an exception. I would like to have some sort of failsafe in position for events like this. One approach would be to write wrapper functions that encapsulate each api a:
returnCode=DEFAULT;
try...
Hi,
In class design, is it a bad habit if one method calls another method in the same class (For example, 3 methods call 1 method in the same class).
Thanks
...
Hi, I'm having problems to recall the name of doing something with quadratic complexity when it can be solved linearly.
For example, using a get-by-index function to iterate over a linked list instead of just using a next-element is the typical case of this antipattern.
I think it was the "something painter", as a metaphor of a guy tha...
Working on a number of legacy systems written in various versions of .NET, across many different companies, I keep finding examples of the following pattern:
public void FooBar()
{
object foo = null;
object bar = null;
try
{
foo = new object();
bar = new object();
// Code which throws exception.
...
I have an user interface that print user, and I wan't to have a filter by country.
I made a classic <select /> element.
In JSP I have
<select id="country" onchange="return filter();">
<option value="">...</option>
<c:forEach var="country" items="${countries}">
<option value="${country.id}"
${country.name}
...
I'm creating a parser for a specific XML structure and I'm facing a possible hardcoding issue. Here:
private function filterDefaultParams($param){
#FIXME Hardcoding?
return array_key_exists('default',$param);
}
The literal 'default' is a valid tag in the Xml structure, is this hardcoding? May I use another technique to search ...
I searched through the archives and I found lots of questions about what sender is and why you should use the pattern but I didn't see anything about a custom event and the type if sender.
Say I am creating a custom class called Subscription and it implements ISubscription and I have some event args called SubscriptionEventArgs. If Subs...
For those of you who are not familiar with D string mixins, they're basically compile-time evals. You can take any compile time string (whether a literal or generated by template metaprogramming or compile time function evaluation) and compile it as code. If you use a simple string literal, it's basically compiler-automated copy-paste....
Hello,
I have a Request class that can be in one of the following states:
Draft,
Submitted,
Approved,
Rejected,
InMission,
Completed
The state of the Request object can be changed by calling one of the following methods. Each method may include some arguments to further associate some data with a particular state:
void Submit(...
I often find that design patterns, libraries, and frameworks promise great things and sound awesome - until you actually study them and realize that what they say sounds better than it actually is.
Completely modular and stackable - use
only what you need!
For example, how do you properly Unit Test your database if your applica...
I am developing a java webapp, using jsp/jquery/ejb/jboss.
I have a web-form that enables the user to select any combination of 100 fields (all from different unrelated tables/objects) from the database. These fields are then output, via a java servlet, to an excel spreadsheet. A stored procedure is executed that always returns all 100 ...
I'm using this statement
//some code
int a[][]=new int[5000000][5000000];
//some code
and running it with command
java -mx512m Test
It is giving OutOFMemoryError: Java Heap space indicating the line number of the mentioned statement in the stacktrace
How do i solve this problem
Edit:
I'm trying to solve a practice problem on cod...
So we have this huge (is 11000 lines huge?) mainmodule.cpp source file in our project and every time I have to touch it I cringe :-)
As this file is so central and large, it keeps accumulating more and more code and I can't think of a good way to make it actually start to shrink.
The file is used and actively changed in several (> 10) ...