I have three classes:
Client
Session
Socket
Both Session & Socket depeand on the Client to create both objects.
A Session depeands on a Socket and no sockets are created without a session.
Should the Client have a function that creates a Session pubically and a Socket privately?
Doesn't it violate the law of demeter?
EDIT:
Current ...
Hey,
I have a need to mirror a byte's value around the centre of 128. So, example outputs of this function include:
In 0 Out 255
In 255 Out 0
In 128 Out 128
In 127 Out 129
In 30 Out 225
In 225 Out 30
I'm driving myself nuts with this, I'm sure I'll kick myself when I read the answers.
Cheers
...
We have a requirement from customer that if someone gets access to the database, all data that includes personal information should be encrypted, so that when they do select calls, they shouldn't be able to see anything in clear text. Now this isn't any problem for Strings, but what about bytearrays? (that can potentially be quite huge (...
Weird question but here it is. What are the programming concepts that were "automated" by modern languages? What I mean are the concepts you had to manually do before. Here is an example: I have just read that in C, you manually do garbage collection; with "modern" languages however, the compiler/interpreter/language itself takes care of...
I just usually do applications for myself as a hobby. It looks like DI frameworks have a big momentum in the community, so I thought maybe I should learn it to improve my coding skills. From what I understand, it seems to be geared more towards big projects. Is it still a good idea to use it for example in a 5k lines project?
Thanks
...
I have a page, where I have approximately 90 items I need to output. Most of them are object properties (I am using ORM so these objects map to my database tables). But the question is, do I have to encode each of those 90 outputs by applying functions to each (in my case, the htmlspecialchars)? Wouldn't that add a bit of an overhead (ca...
I recently began to start using functions to make casting easier on my fingers for one instance I had something like this
((Dictionary<string,string>)value).Add(foo);
and converted it to a tiny little helper function so I can do this
ToDictionary(value).Add(foo);
Is this a code smell?
Also, what about simpler examples? For example...
Possible Duplicate:
What are your programming exercises?
Are there any programming exercises that apply to any language? Before I got my first job, I thought I knew C# pretty well, then I was thrown right into the deep end, and now I know I have a good command over the language.
I would like to apply the same method to other ...
Is there a convention for the order of (height, width) in function arguments or when displaying dimensions?
...
Suppose I have a list of strings where each string is
exactly 4 characters long and
unique within the list.
For each of these strings I want to identify the position of the characters within the string that make the string unique.
So for a list of three strings
abcd
abcc
bbcb
For the first string I want to identify the character ...
Recently someone stated that they thought all Creates should be CreateOrUpdates. Instinctively i thought bad, but now I am trying to find out if I have any grounds.
Situation
interface IService{
void Create(Object a);
void Update(Object a);
}
or
interface IService{
void CreateOrUpdate(Object a);
}
My first...
I would like to know, what are the ways a web framework may be suitable for designing a RESTful app, in general.
One goal is for example to provide http request routing, so they are automatically sent to appropriate controllers. From architectural point of view, web framework based on MVC pattern are more suitable for REST.
What other ...
Take Java syntax as an example, though the question itself is language independent. If the following snippet takes an object MyAbstractEmailTemplate as input argument in the method setTemplate, the class MyGateway will then become tightly-coupled with the object MyAbstractEmailTemplate, which lessens the re-usability of the class MyGatew...
Other SO threads have asked people
if they prefer N-Tier or MVC
architecture.
I'm not looking to
continue that debate on this thread.
I'm looking for something more specific.
My Question:
Does Anyone Still Prefer N-Tier Architecture After Having Shipped an MVC Application?
Reason for My Question:
Before I shipped an MVC web ap...
I have classes like this one:
class SomeObject
{
public function __construct($param1, $param2)
{
$this->process($param1, $param2);
}
...
}
So I can instantly "call" it as some sort of global function just like
new SomeObject($arg1, $arg2);
which has the benefits of
staying concise,
being easy to understand,...
I have the following structure:
MyClass {
guid ID
guid ParentID
string Name
}
I'd like to create an array which contains the elements in the order they should be displayed in a hierarchy (e.g. according to their "left" values), as well as a hash which maps the guid to the indentation level.
For example:
ID Name ParentI...
I have been getting very frustrated recently in dealing with a massive bulk of legacy code which I am trying to get familiar with.
Say I try to search for a particular function call, I get loads of results that turn out to be completely irrelevant; some of them are easy to spot, eg a comment saying
// Fixed functionality in foo() so d...
In other words - what would be a good name for a variable that references the currently logged user?
I've come up with a few:
logged_user
visitor
me
I'm not convinced either of them is good enough though.
...
Rush Hour
if you're not familiar with it, the game consists of a collection of cars of varying sizes, set either horizontally or vertically, on a NxM grid that has a single exit.
Each car can move forward/backward in the directions it's set in, as long as another car is not blocking it. You can never change the direction of a car.
There ...
I am aware of this question which deals with the technical aspects of website construction, but I was unable to find any place with suggestions on knowledge you must obtain from a client before undergoing a project. As someone who freelances on the side, I think this could be incredibly useful.
What important questions must one ask the ...