instruction
stringlengths
34
19.9k
Many of the readings I've done on DDD, both in books and online, seem to represent code that, often times, is difficult or impossible to unit test. For example, there are numerous samples with static factories, calls to concrete domain classes and static extension methods (in C# samples only). I find it frustrating and...
Does anyone know of an existing name for a bug that disappears the moment you call someone over to look at it? It's a funny phenomenon, but it has happened from time to time that I'm working on a bug that consistently appears, but as soon as I call over a colleague to look at it with me, the buggy behavior stops and d...
I need to play devils advocate on this question a bit because I cannot defend it well because of lack of experience. Here is the deal, I get conceptually the differences between unit testing and integration testing. When specifically focusing in on persistence methods and the repository, a unit test would use a mock po...
I'm working on a legacy system (by that I mean it was written without tests). We've tried to test some of the system by writing integration tests that test functionality from the outside. This gives me some confidence to refactor parts of the code without worry about breaking it. But the problem is these integration...
I understand that the model should generally consist of data manipulation and the view for data display from the model, but how do I keep my model and view layers decoupled? My simple view has a few tables that display data. Its associated model manipulates the data based on the view's type of TableModel. Most of its m...
I don't use design patterns very often, besides an occasional factory and MVC, and I want to start using them more. I have a concrete case at hand that I would like your opinion on the use of design patterns in this case. In my application I have to convert objects pretty often in different situations. I might have to ...
I have not personally come across a situation where I've needed to use WeakReference type in .Net, but the popular belief seems to be that it should be used in caches. Dr Jon Harrop gave a very good case against the use of WeakReferences in caches in his answer to this question. I've also often heard AS3 developers tal...
I'm currently using an open source project called CodeFirstMembership for one of my projects. There's a critical issue that I need to get past, and the more I use it, the more I find things I need to modify. It's extremely useful, except it doesn't look like the developer has much time to update it (totally cool, we'...
In the field of web development, is it good practice to do a POST/Redirect/GET when fields in a form submission are invalid, as well? Typically, no sensitive transaction would have taken place, in this event. However, can an argument be made that, nonetheless, it is still good practice to utilize the POST/Redirect/GET ...
A small group of friends (including myself) decided to develop a simple 2D game. We are all fairly new to software development, so I wanted to ask which software development model would likely work best for such a group. From the list on Wikipedia, the Waterfall and Spiral models seem to be the two best options. Our pl...
I am currently working on a rails project and have a requirement where I want to be able to map a country name's initial letters to its ISD code. eg: IND => 91, USA => 1, etc. The broader question here being (notwithstanding which framework you work on), what should be the best practice to store these things. Should yo...
As all of us know that after IPv4 it came IPv6. How this transition happened? I just want to know was there any IPv5 also? or there is any other logic in naming this version of IP as IPv6?
I have worked as a software engineer for more than 6 years. Recently, my boss has asked me to build and manage a virtual team. While I'm glad I can do some management work, I don't think it will be easy to do the management. My team members are only part-time on this project, they come from several teams, and their di...
According to the commonly used TDD strategy, to implement something, you write a test that fail the code first, write the simplest code, refactor, and then repeat. I am trying to imagine this scenario with implementing a flexible length list (e.g. List<T> in .net. Let's say I first test by inserting one item. Probably ...
Having read SO, just found this question: if (x > y) print (x) else if (x < y) print (y) else print (x,y) How many branches and decisions are there? It mentiones there should be 3 decision and 5 branches, yet I cannot see how. For me I can only imagine 4 branches (2 Ifs with two possible results). Origi...
I've a maturing idea regarding a knowledge store. For the purposes of this question, the store would be used by a police force for the recording and querying of crimes. I believe that historically, police forces used to hold vast index card systems, allowing cross-correlation and querying. The knowledge store would ...
Reading 21st Century C I arrived at chapter 6 at the section "Marking Exceptional Numeric Values with NaNs", where it explains the use of the bits in the mantissa to store some arbitrary bit patterns, to use them as markers or pointers (the book mentions that WebKit uses this technique). I'm not really sure I understoo...
I want to read Purely Functional Data Structures. I've easily found the thesis (which is freely available as a PDF), but see that there's a book available also. So I'd like to know what the differences are, if any, between these two publications.
I have an existing Scala application that I am trying to refactor in order to use Akka. One of the problems I have is how to manage error-checking in actor-based applications. Usually error-checking is done through one of two mechanisms: either one returns a value indicating an error condition, such as Option[A] or Fa...
What is a hidden AJAX request? I've noticed an increase in the usage of hidden AJAX requests designed to make a user's action appear to happen immediately. I'll refer to this type of AJAX request as non-blocking. It's an AJAX request made without the user being aware it's happening, it's performed in the background and...
I'm working on a web application that sits on top of a number of RESTful web services, interacting primarily with those services through JSON formatted messages over HTTP. Our application has a great deal of static data that are read from these services (internationalization lookups, configuration, etc.) during operati...
I have a C#/SQL Server program that sometimes needs to store data. The data could be a response from a web service, a result of a database query, or any number of other things. There's no way of knowing before the data is stored how many fields it might have or what the data structure might be. We have this kind of pai...
We are about to write our first WPF application and are becoming familiar with the MVVM pattern. We've built many Winform applications and have an architecture that has been very successful for us. We're having a little bit of trouble translating that architecture or determining where certain pieces of our architectur...
I've just released a small Java library that offers only a few classes and methods. Since I built the project with Maven, I immediately used several third-party libraries to achieve my goals, specifically: commons-lang3 (for some general Java stuff) slf4j-api (for logging) commons-io (for a tiny bit of file stuff - li...
Given the concept of 'skinny controllers, fat models' and the general acceptance that Views can directly call on Models when requiring data for output, should one consider handling the 'get and display' parts of requests within the Views and not the Controller? For example (attempted to keep code fairly generic): Contr...
We're using final builder to build a Delphi project and the person managing the build server noticed that projects with no .dres files were not building because they're not in SVN and because they're not in SVN they're not on the build machine. So he put them in SVN. I'm a little skeptical about the necessity of pu...
First off, I'll admit that I'm a newbie to DDD and need to read the "blue book". I'm building a system that has an AggregateRoot of type "Match". Each Match can have a collection of "Votes" and also has a readonly "VoteCount" property which gets incremented when a user up-votes or down-votes a Match. Since many users ...
I want to better write code with pen and paper. Whether it'll be in pseudocode or real code, doesn't matter. Could you kindly advise me sources for this?
I have this problem called out by PMD (static code analyzer) more often that I would like, and would like to know how someone with more experience than me would write it. My code is functional but I find it inelegant, so I want to know how other programmers would write this piece. The case is, in a network/IO petition ...
So, we have just migrated from SVN to Perforce. I'm having a little trouble trying to figure out the best workflow. For Subversion, I did the following (via TortoiseSVN): Check out repo Do work Update repo Resolve conflicts, if any. Commit my code. Do work.. What is the best approach for P4? I know that you must open...
I'm parsing a set of XML files of different kinds (these kinds are known in advance). These are my requirements: I want an object to represent each XML document (object-xml mapping) I'd rather have a different class for each kind, so that identifying the type of the XML file is equivalent to looking at the class of t...
Let's say I have a hierarchy of Item classes: Rectangle, Circle, Triangle. I want to be able to draw them, so my first possibility is add a virtual Draw() method to each: class Item { public: virtual ~Item(); virtual void Draw() =0; }; However, I want to split the drawing functionality to a separate Draw libra...
I started building a web crawler and read somewhere that it's a very hard problem to find a good seed page for the crawler. Can anyone explain me if there is any pre-defined procedure/ guidlines of finding a good seed page? or how you say that a particular page is a good seed page?
I'm working on a project where exist one method with title string ValidateNewPasswordExpireCurrentPasswordAndCreateNewPassword(...) I'm sure the method name must be changed. But can't found good and descriptive alternative. Also I can't separate method in multiple methods, like ValidateNewPassword(), ExpireCurrentPas...
I am working on a module which is dependent on other module for some functionality. Now the dependent module provides a lot of functionality and I need only few of them, hence got the idea to create an abstraction of the same in my module which is again be a singleton only. My question is when to abstract out and when ...
The W3C spec on the class attribute says There are no additional restrictions on the tokens authors can use in the class attribute, but authors are encouraged to use values that describe the nature of the content, rather than values that describe the desired presentation of the content. Reference I work on a massive ...
I'm currently working on an open-source project. Currently, we put our copyright notice at the top of every Java source file. I was wondering whether it was advisable or common practice to put copyright notices in CSS or XML files.
Today I read on Fossil SCM's mailing list: The problem with BSD is that you really should get a signed form from each contributor stating that their contribution is BSD. This is automatic with GPL, since releasing your contributions under a compatible license is a prerequisite for viewing the code in GPL. This...
So I understand the importance of Polymorphism, including how vital it is. But something I don't quite understand is what about the Constructor and any inherited Class the initial Base Class may have. For example, I have a class to test some criteria- Level of account, Windows Version, and some other checks. // Base C...
I have almost a 'best-practice' question that's been nagging at me for a while. When I use JavaScript libraries and APIs such as JQGrid or Google Maps, I tend to find myself creating server side libraries to render the JavaScript for me. For example I might have: $map->setZoom(10); $map->setDimensions(200,250); in PHP...
I just learned about currying, and while I think I understand the concept, I'm not seeing any big advantage in using it. As a trivial example I use a function that adds two values (written in ML). The version without currying would be fun add(x, y) = x + y and would be called as add(3, 5) while the curried version i...
I have applied and have been approached for different roles in web development recently. The one thing that keeps coming up is that I am more suited to front end development than back end development. This makes sense given my background starting out as a designer. The problem is that while I have worked on a large ap...
I am looking for feedback on the design of my program. I have a shell script call function.sh that defines a lot of helper functions. My intent is to use those bash functions defined in functions.sh in a C program. I am doing this so that I don't have to rewrite the bash functionality (in functions.sh) again in C. I wa...
See top answer here: Obfuscation at source-code level more effective than obfuscators?, specifically "Code it in a language so not easy to decompile such as C/C++" I'm looking to write a new application that will be sold for $500 per license, so I'd like to prevent decompilers. Should C# be avoided, or is using an obfu...
I do a lot of development in my own time. These projects I work on are all just for fun and learning (so far). I commonly do Java development with Maven but I have also been known to dabble in .NET and Python. All of the projects I work on use open source licenses, although most of them are not on any public code repos...
Is there are any standards or conventions on naming methods which add something if it not exist into another something. For example: Store.instance().addItemIfNotExist(item) IfNotExist is really ugly part. What workaround may be?
Say I have a typical MVC setup. The controller passes on some input to the model, and asks it to do something with it. But the validation of the data fails, or there is some other problem. What's the best way of getting these errors passed back to the controller, which will then pass them to the view to be displayed to...
I come from c++, where one declares all assets to be included at the top of a file. That is what I have been doing with php as well. Lately I have been tempted to stray from this rule: I have a script file where I put functions I use throughout my projects, sort of like a library script. There are some functions includ...
I have been programming in google Golang and have been enjoying it due to its brevity but I find it surprising that almost all its Math standard library methods are for the floating point type. Is there any particular reason why these methods do not exist for ints?
I'm conceptually trying to understand if I should be doing this: item = Model() screen = View() brain = Controller(item, screen) or this.. brain = Controller() item = Model(brain) screen = View(brain) or this.. class Controller(): def __init__(self): item = Model(self) screen = View(self) or some...
Is it a good idea or a bad idea to create an interface for data transfer objects? Presuming that the object is usually mutable. Though my example is in Java, it should be applicable to any other language that has similar concepts. interface DataTransferObject { String getName(); void setName(String name); } ...
I guess this is more of a "comfort seeking" question than legality one. You see, for the past couple of months I have been brainstorming and developing a product, all by myself. I was planning to release it under some kind of free license. While I know no idea is ever a unique one, I was quite happy to note that the wa...
I have been told that the average number of bugs/defects per line of code is "constant" for different programming languages. 10 KLOC of Ruby would have the same number of bugs as 10 KLOC of c++. The argument is usually used to promote the use of expressive languages (think python/ruby over c++/assembly) since the numbe...
I just wanted to know what is the significance of SRS(Software Requirement Specification) in programming? and what are the techniques used in preparation of an SRS .. also who writes the SRS.. is it the programmers?
Possible Duplicate: Where did the notion of “one return only” come from? I got into a little argument with a coworker about whether a method should be written like this: public Thing getThing(int key){ if(!things.containsKey(key)) return null; return things.get(key); } or this: public Thing getThin...
I mean, it is possible to create application without source code - for example using HEX editor or some debugger that can assembly instructions (actually every decent debugger can). Creating programs this way is of course hard, but possible for small applications. I even can imagine cases, where it is the only possible...
I've been toying around with Ruby lately and I found myself wondering if in pure object oriented languages (and even those that are not pure) making methods that take only one parameter and then get chained together is equivalent to currying in languages with a functional style? If not, why not? I'd appreciate a detail...
Understanding what a pointer (an address) is, is fairly easy and an eleven-year old can understand it. But how do we express why we have a need for a pointer to a pointer? what is a very pedagogical example? Does it extend to pointing to a pointer to a pointer (and/or onward)? Example problem T[][] does not decay to a...
Our software implements a layer of role-based security to secure data access, in the form of access control lists. Whenever a user tries to do something that isn't allowed, the software layer will receive an "access denied" error code or exception. Having seen how our customers react to such "access denied" messages, a...
I am trying to implement the trapezoidal rule programmatically but am having trouble finding a good way to input the function of x and then have a loop which will iterate through for each sub-interval finding the area of the trapezium and adding the results and returning it. Any help would be awesome.
Possible Duplicate: Understanding the bridge design pattern I have read lots of material about the bridge design pattern: http://www.codeproject.com/Articles/3151/Illustrated-GOF-Design-Patterns-in-C-Part-II-Struc http://sourcemaking.com/design_patterns/bridge http://en.wikipedia.org/wiki/Bridge_pattern Understandi...
The automated bell system of Stateless University should ring every hour during Mondays, Wednesdays, and Fridays. It should ring every 90 minutes during Tuesdays and Thursdays, and does not ring at all during weekends So the equivalence classes for these are: Mondays, Wednesdays, Fridays Tuesdays and Thursdays Saturday...
I'm producing a binary distributable for my Java project. I'm releasing it in two ways: Maven Central Zipped distributable on Google code My project is licensed under the Apache 2.0 license. I use a small number of third-party parties, one of which is MIT licensed. I believe it's my obligation to make users of my pro...
Let's say you're writing a Yahtzee game TDD style. You want to test the part of the code that determines whether or not a set of five die rolls is a full house. As far as I know, when doing TDD, you follow these principles: Write tests first Write the simplest thing possible that works Refine and refactor So an initi...
I understand the benefits of injecting dependencies into objects, but have not found much guidance on the types of objects to inject and when to make them singletons. If we take as as example an application with the following types of objects: Services (including repositories and business services such as calculatepri...
I'm researching engineering approaches to software development based on the type of software, for example: Custom one-off software (e.g. space shuttle software) Whitebox application requiring customised (e.g. Apache Ofbiz ERP - source code is usually downloaded and customized for each implementation) Blackbox applicat...
We have transcripts of around 8000 videos. However, these transcripts do not have any timed text (ie: they are not time coded to the video) We are trying to ascertain whether software exists, or what approach to take to automatically time code the transcript to its associated video. Does software exist to do this? If ...
After going through a lot of articles and this post, i know Why doctypes are used for and also about the different modes triggered by the browser like standards, quirks etc. I downloaded the a strict doctype from this url - http://www.w3.org/TR/html4/strict.dtd but couldn't understand a thing of what is written inside ...
As a follow up to Does a BSD-licensed project need a signed statement from each contributor?: There are several reasons why an open source project might want to get copyright assignments from its contributors. For example: To allow the project author to sue for infringement (as only the copyright holder can do so). Th...
My team of about 70 programmers is developing C and C++ code for embedded, multiprocessor, image-processing project. We have a coding standard, and hold design and code reviews. The problem is that we don't have solid design review checklist. Currently we have scattered design checklists, but most of them are vague. Fo...
I am currently working on a web app and want to design the interface between nodejs / mongoose and the backbone app. A short description of the app: A user signs up to the application and gets a user account where he can create an organization (e.g. footballclub). Within these organizations you can set up projects. Wi...
Our team redesigns the legacy software and there are a lot of design meetings going on. Many of them are not very effective and lack good analysis of the proposed design. Is there any formal way to approach this kind of discussions to make them more effective? I heard about SWOT for example, but afaik it is used more f...
I have a list of english words. I'm trying to come up with a data structure that allows me to do fast StartsWith filtering, like: var words = dictionary.StartsWith("foo"); I was thinking of creating a data structure like this: But I wanted to ask first: a) Does the above data structure already have a name? b) Is this...
When you are working with a multi-tier application very often you run into task of converting objects in one layer to objects in another layer. This could be converting database objects into domain objects, service objects into domain objects, domain object into view models, etc. I've seen it being done in multiple way...
There are essentially two camps of library designers concerning the design of the final header file inclusion: Provide a single header file that includes every other header file that makes up the public API. For example, GTK+ dictates that only gtk.h shall be included. This does not mean that everything is explicitly...
We have to develop our own file management system in Java web application. We need to sync files between our main server and client severs and find out whether all the client server has all the latest version of files. Our files are in pdf, doc and xls format they changes every now and then as and when it is required. ...
I just started learning Haskell and it seems like you can't get too far in the language without being comfortable ( or at least exposed ) to certain branches of mathematics. Unfortunately I have major holes in such areas and am wondering what is a good introductory textbook that covers all the concepts Haskell uses? Fo...
until now I was using dropbox as my main vcs (it is not, but for a single dev does the job pretty decent). However I decided to give git a go and see if it fits my needs. Today I was reading this tutorial and at some point it says: One of the things you should get used to is doing development in a separate area, no...
When I first started to learn programming I remember having an argument with my teacher about If Else statements. I was arguing that: if { ... } else if { ... } ... is basically the same as: if { ... else { if { ... } else { if { ... }...
We have tried to introduce developer automated testing several times at my company. Our QA team uses Selenium to automate UI tests, but I always wanted to introduce unit tests and integration tests. In the past, each time we tried it, everyone got excited for the first month or two. Then, several months in, people simp...
I have created a very tiny framework to be able to get away from all the clutter while developing. The point of the framework is not to replace any library of choice but simply segregate the code to it's correct logic. You can see the source on github along with a few code examples: https://github.com/erik-landvall/sh...
My programming professor has told me that it is a good programming practice (at least in C/C++) to declare a function with the inner loop when nesting loops (not for loops, since when, i.e. looping through a multidimensional array this is very intuitive). For example, if I write int main() { while (cond1) { ...
I have to create a validation system(I don't want to use Data Annotation or any other system) for my C# application using .Net Compact Framework, where I have an object which contains many other objects. Many of the properties are dependent on each other means they have some sort of dependencies. I can write a simple v...
So I have a program I'm worked on back in 2011 and all through 2012, but the last release was in December of 2011. I've been actively working on it, but feature creep lured its ugly head and now it is filled with tons on unfinished features. The bad part is that as I implement a feature, a new one creeps in. What can I...
I sent out an email earlier reminding our developers that the use of the word "shall" in your derived requirements should not follow over to your functional requirements. When writing functional requirements the word "must" is used to describe the function a derived requirement must do. Derived = System Shall be req...
I have encountered (even in literature) two contradicting opinions related to path vs condition coverage (not branch or edge!). Some say Path coverage is stronger than the condition coverage, some say the opposite. Having code like this: If(X<0 OR X>100) DoStuff(); Path coverage - 1 test case is needed to cover the...
In TDD, is it good practice to keep the tests in the same directory as the code its testing or is it better separate the tests in either a different directory or a separate project. Would it be the same for a web site where you have the aspx/c# pages in one directory?
Basically, we have three main projects, two of them are web services, and the other is a web application. While I'm satisfied with covering as much as we can of our web services with functional tests (all three projects have their proper unit tests), functional tests for the web application are taking a lot of develope...
Recently my company was asked by a customer to develop a control board that includes firmware and PCB layout development. After finishing development the customer will buy the control boards at certain quantity every year. We are now at making contract stage, the customer is wanting my company to handover both the firm...
I like that SourceForge can also let people browse your code using Git. But, before I even set up the project on SourceForge, I had a GitHub repository for it. Now that I have created my SourceForge project, I had the option to use the Git tool. The problem is when I did that it made a new repository from scratch. I wo...
scenario: I have an entity called Member. Members fall into multiple types. Some types are below. Supporter Volunteer Sponsor Player I can create class for each type and inherit from the base Member entity. But when a Member has more than 1 type in a given time, it is not the right way. can I use decorator pattern t...
One of my team members consistently avoids making comments in his code. His code is not self-documenting, and other programmers have a difficult time understanding his code. I have asked him several times to comment his code, however he just gives excuses or claims that he will do it later. His concern is that adding ...
I am a Software developer who works on J2SE (core java). Often during our code reviews we are asked to reduce the number of lines in our code. It's not about removing redundant code, it's about following a style that focuses on doing the same things with fewer lines in the code, while I believe in having clarity in cod...
Now and then I use the Python lambda. Is it so formal that it is safe to say that you can do formal lambda calculus with it? I just used it but I didn't fully understand whether the python lambda and the lambda calculus like I read was done by Alonzo Church. I also used it in Javascript, I think. Isn't this more common...
Before I start this question I know the java 'goto' is a big no go. So I've been writing a program and I have some indented Loops and statements and I need to BREAK multiple on command. Rather than having a load of boolean variables and if(!<booleanName>) BREAK; statements throughout these loops and statements what is ...
This is a problem me and my team faces in almost all of the projects. Testing certain parts of the application with JUnit is not easy and you need to start early and to stick to it, but that's not the question I'm asking. The actual problem is that with n-Threads, locking, possible exceptions within the threads and sha...
I have been doubting for a long time whether or not to have a logger in methods (usually helper methods) like the one below. Whether we can print it in the method or print the response where the method is called. public String getAddNewUserUrl() { String url = null; String mode = null; try ...
I've had some discussion with colleagues who chose to go with JRuby along the following line of argumentation: JRuby can make use of anything that is available in Java, ergo such programs are more portable bc Java is more portable. Arguably, the breadth, capability and speed of C/C++ libraries that have been wrapped fo...
Each time I see a question posted on Stack Overflow on C#, I see at least one or two answers posted that solve a problem with LINQ. Usually people with very high reputation seem to use LINQ like pros. So my question is, what problem domain is LINQ supposed to be used for? Also on side notes: Are there any purposes in w...
A friend and I have started a project using code from another project, that is covered licensed under GPL. We have distributed it freely on our website, and under its download button, we've added a direct download link to the modified source code also for free. At the about section of the application, we have credited ...