instruction
stringlengths
34
19.9k
I've got a Python project wherein a basic object is created and various different attributes are modified/given to it via what I thought was a good example of a strategy pattern. In this silly game there are enemies with multiple different potential patterns of movement. The Enemy class has a basic pattern of movement ...
I'm not quite sure what the real practice is in the programming community. But when a user deletes content from your service (ie. deleting a status update, a photo of theirs, a comment they made). Should I actually delete them from my server or just hide it? The reason why I am asking this is because we live in a age w...
I have a large list of intercommunicating components; so I decided to have one class create all of them and then subsequently delegate them to other classes to facilitate finer tweaking and wiring together. By "finer tweaking", I mean that the components are modified to their final state; and by "wiring together" I mea...
This is a question that's been on my mind for a while. Recently I've been checking out concurrent languages like Haskell or Go or Erlang. From my point of view, they have huge benefit in performance as opposed to languages like C++ or Python because of the way they handle functions in parallel. My question is: Why is t...
I had an idea (which I'm sure already exists), to create a sort of 'network of observers/subjects'. I would like to describe how it works and than ask several questions about it. Say we have 5 objects: Objects A, B, C, D and E. Objects D and E need to observe objects A, B and C. With the regular Observer pattern, both ...
I'm trying to understand how the Dependency Inversion Principle differs from the "program to an interface, not an implementation" principle. I understand what "Program to an interface, not an implementation" means. I also understand how it allows for more flexible and maintainable designs. But I don't understand how th...
Is it recommended that TDD be always practiced in a project, or are there cases when it should be avoided? Should we all adopt TDD? Is it standard practice in major software companies?
Our company is trying to follow Agile methodologies when it comes to estimating and prioritizing any new development work. The reading I've done makes this concept appear great so we are trying to give it a good crack at making it work for us and hence help with providing a better solution at the end of the day for ou...
Given a large group (50+) of programmers: All given the same problem, All using Test-Driven Development (TDD), All pair programming, All doing group-based code review, I have personally seen the wide spectrum tests that are possible for the same problem, even on the first test. So, if TDD is design, how do you know y...
We are working on ASP.NET webforms application developed using WCSF (MVP pattern). In the application, there is a search screen that allows the user to enter some fields and display the results. We have segregated the functionality into user controls and each user control has its own view and presenter. Search -> It ...
For the entire past year I've been written Scala code (coming from a Java background). I really liked how you could create simpler and cleaner code, with vals, case classes, map/filter/lambda functions, implicits and the type inference. I've used it mostly for an Akka-based application. This year I'm on a Scala project...
Let's say you work for a company and what you do is develop software for them. You have no idea of the big picture or maybe slight. What you do have are tasks assigned to you via issue tracking system. You're given tasks, you make them work the way the task describes them, you send them back. Like adding 2 integers: fu...
I have a class Container containing objects of type Item. They are different classes, and especially they have no common base class (e.g. a Container does not itself have a Container).: class Container { public ICollection<Item> Items { get { /* ... */ } } } class Item { public Container Container { get { /* ....
Why does Python use hash table to implement dict, but not Red-Black Tree? What is the key? Performance?
I am trying to figure out how to architecture my project in the DDD paradigm (a complete beginner in DDD) and stumbled upon a problem about the implementation of the web services... These are some options that I see: Fat client, Fat server (option 1): Server: Repository layer: talks to database and can return domain ...
In the manufacturing of a device each one has to get a unique identifier. So far so good, one can have a file containing the last used ID on a shared drive, or a network-based service managing and assigning IDs so that the uploading of the ID into the device will not be limited to a single workstation. However, in the ...
Why do so many people recommend offloading email to a transactional service such as Mandrill, Postmark or Sendgrid? Is sending email via smtp really that much slower than sending a request out to said service? I imagine it has something to do with the rendering of the actual message, but I'd like a more informed reason...
Consider this license I wrote for my software: Copyright 2014, [my name] The author(s) of this software intends to provide the users with the maximum amount of freedom. As such, this software may be used under any one of the following licenses: 1. MIT: [link to the license] 2. Apache 2.0: [link to the license] 3. BSD...
The following code give the identity matrix of any size the user wish it to be: program identitymatrix real, dimension(:, :), allocatable :: I character:: fmt*8 integer :: ms, j print*,'the size of the matrix is?' read*,ms allocate(I(ms,ms)) I = 0 ! Initialize the array. fora...
Is it necessary to use interfaces for small projects? I work at a shop writing small custom applications for clients, primarily data manipulation. I'm mostly self-taught but also took some programming classes in college. I've been trying to apply more OO concepts to my coding practices, but I really don't see the need ...
Alexander Stepanov stated in talks and interviews that his realization that eventually lead him to generic programming and the Standard Template Library, was from the case of the parallel reduction algorithm. Why isn't there parallel_reduction(begin,end,associativeop) in the STL? Or something that could easily be turne...
Referring to the image here: From http://en.wikipedia.org/wiki/File:X86_Paging_4K.svg Could somebody please explain something for me? I don't get exactly how this works. As I understand it the page "directory" contains an entity which essentially points to the beginning of the "page table". However, surely all of the...
I have a web application that uses MongoDB as primary database. This is the first project I do with a NoSQL DB. I'm trying to create the application model but I'm confused. I know NoSQL databases are non-normalized and it is normal to replicate data avoiding joins (which are not supported) but I'm now thinking of this...
my IT boss wanted this scenario to be undertaken: First, we develop an Alumni program using PHP and deploy this in the web server which can be accessed by that school alumni in the web to update their personal data anytime. Then, using exactly that SAME program we must also deploy this locally, thru the LAN in its sate...
I recently had a discussion with a friend of mine about OOP in video game development. I was explaining the architecture of one of my games which, to my friend's surprise, contained many small classes and several abstraction layers. I argued that this was the result of me focusing on giving everything a Single Respons...
Design by Contract says, in terms of the function talking: "you give me all the right parameters and I'll give you exactly this kind of data" ...in essence. So, given that, should I use up resources checking the output? I should check for properties that the function does not guarantee its output possesses, but the pr...
As far as I know, declaring an interface is like so: public interface Roots_Squares { public double square_root( double value ); } Now... how do you enforce value to have non-negative values? Such a function should avoid negative values right? If someone creates a class that implements this, and that implementat...
My team is working with git for the first time and has really messed up our git remote due to our inexperience. I'm trying to help educate them on git to solve the problem in the long term, but in the meantime, the commits that have been made are totally wrong. We haven't made very much progress at all, and I don't see...
The build server at our company sucks. The build agents (there are a dozen of them, each is a separate VM, and apparently they are all living on their own ESX server) are SLOW. The web interface is SLOW and is running on a Windows VM, also on ESX. Everything is SLOW, SLOW, SLOW. Artifact upload sometimes fails for unkn...
I recently had a small "argument" about inheritance with a friend. I think people overuse it a lot. Intuition tells me that that the only good reason for class inheritance is polymorphism - when there is a case that you want to treat uniquely object of different but related classes. Our argument was about having a Base...
I often see the advice that you should try to make each library independent. And yet in reality I can never seem to achieve this. Is this BS advice or is it actually possibly in any realistic way? Example: I write a 2D Vector library, I then use that to make a 2D collision library. I then build a 2D physics library tha...
An agency wants to develop a highly secret computer system using public contractors. So they hire different companies to implement different components of the system. When all the components are put together the system is functional, but each component on it's own does not reveal the true nature of the system. Often t...
I'm trying to get some pointers on what the best methodology to follow for a web application would be. First, some background: I've built two different APIs using Node.js where Node serves the data to clients using a JSON interface. The clients have both been iOS applications, making heavy use of Socket.io and Express....
I primarily develop in .Net, and have been playing around with F#. It's a nice concise language, but I'm just using it for throwaway code currently. I've taken to sitting my tests in the same file as the main code that I'm writing. I am under the unexamined opinion that this is done so that we don't have testing code f...
Thinking about the design of a potential new language, I wonder how related are the concepts of built a OO similar to GO interfaces and multi-methods (I get this from http://docs.julialang.org/en/latest/manual/methods/). If I understand this right, the interfaces are simply a group of methods that must be implemented b...
I did my homework, and it says that dynamic data structures are "data structures that change in size as a program needs it to by allocating and de-allocating memory from the heap". So I was wondering, are PHP arrays examples of dynamic data structures, or are they limited to binary trees and double-linked lists? Thanks...
I am trying to write a branch and bound search on the set of all functions f: D -> R, where the domain size is small (|D| ~ 20) and the range is much bigger (|R| ~ 2^20). Initially, I came up with the following solution. (builder (domain range condlist partial-map) (let ((passed? (check condlist partial-map...
I am using a bunch of freelance programmers to develop a web application. We are in the early stages of development, meaning that we are making many changes to our database schema. We have one test database and one production database, we also have a replica of the live database, which gets a clone of the live database...
These options which obscure me are like ps aux, route -ee, gcc -fPIC xxx, find . -name xxx and so on. The examples above aren't comprehensive. I.e., I don't think that the argument handle function like getopt or getopt_long could handle all the "strange" options. In the other hand, these handle ways aren't intuitive...
I am wondering how to test .aspx.cs and .ascx.cs code behind. Can I use unit testing and if so how? Are there alternatives that will help test the functions in the code behind files? I don't know how to mock the page or control. I would like to try to apply tdd methodology but I don't know how to unit test the code beh...
In localization code (like T('English phrase with %s and %s parameters', param1, param2) the order of parameters in different languages is different. How to handle this? Our localization engine seems not to support named or numbered parameters, so the parameters need to go in the same order as they are in code.
There are bunch of console programs and especially games using full redraw (not sure ho this correctly named) of console window. For example, look at output of linux top program -> http://upload.wikimedia.org/wikipedia/commons/9/9f/Top_program.jpg it doesn't just write text line by line all the time making the whole ou...
I am modeling a class diagram and have spotted an opportunity to simplify it slightly. What I want to know is, would this it be better to implement an abstract class or an interface? The scenario is this, I have the classes: Artist Genre Album Song All of which share the methods getName, setName, and getCount (playc...
I am wondering about performance of a web site/application when there is code in the code behind files rather than when the code is moved to separate files in the App_Code folder. My understanding is that the code behind gets compiled and executed every time they are requested by the user. If this is not the case, ple...
I've been confused for a while about the differences between the patterns Factory Method and Abstract Factory. Been doing a lot of research, still confused. I have one question: Is the only difference between the two patterns, is that Factory Method produces one object, and Abstract Factory produces a family of objects...
For a project, I need to work with varying types of files from some old games and related software--configuration files, saves, resource archives, and so on. The bulk of these aren't yet documented, nor do tools exist to work with them, so I must reverse-engineer the formats and build my own libraries to handle them. A...
I'm trying to understand when is preferred to use recursion rather than iteration. Actually I've encountered recursion only in Javascript but never in Python. I imagine that recursion should be used in determinate contexts or languages but I don't understand when I should use it and which advantages it gives me. I woul...
Question: As an lone, Agile (PXP/PSP) developer what is the proper structure for a formal project post-mortem? Scenario I'm using a PXP methodology (which is a blend of extreme programming and the personal software process) to work on an undergrad project. The project revolves around computer vision and architecture. ...
You can use << to multiply and >> to divide numbers in python when I time them I find using the binary shift way of doing it is 10x faster than dividing or multiplying the regular way. Why is using << and >> a lot faster than * and /? What are the behind the scene processes going on to make * and / so slow?
Suppose i have an abstract base class Parent which defines an abstract Method A(some parameter) taking a parameter, also it defines an instance Method B which calls method A(parameter) inside its body and passing some parameter.Then we have an concrete child class B which extends the base class and provide its own imp...
What is the industrial practice on how to separate html and php code in a web project? Using echos to generate html is considered bad but what is the standard way to achieve the sought separation? Using template engines like twig?
When studying OOP by myself I often encounter UML class diagrams. I understand them, but don't completely know how to write them. Meaning, I don't entirely know what each kind of arrow means, and things like that. 1- How important is it to learn the 'language' of UML class diagrams? If it is something worth the time, c...
A is a sorted list. B is a sorted list, and a subset of A. If an element is inserted into A at index i what's the most efficient way to determine the correct index i' for it's position in B? Given the fact that both lists are sorted, and that we know B is subset of A I would think we should be able to devise quite an e...
final String str = "do not change me"; str = "why not?"; //it will result in compile time error saying that final fields can not be re-assigned once created i.e. the reference cannot be changed String str1 = "hello world"; System.out.println(str1.replaceAll("h", "q")); str1 = str1.replaceAll("h", "q"); S...
Why do projects opt to stay on an older framework version of the .NET Framework? For example, staying on .NET Framework version 3.5 which was released in 2007 instead of upgrading to the latest 4.5.1 version? Jon Skeet's Noda Time also targets .NET 3.5. Why?
My question concerns deployment scripts in the process of continuous delivery. Continuous delivery recommends that deployment scripts should be versioned into SCM just as normal code. What is the best practice to avoid issues such as checking out (e.g. from Git) a script that does not have the right permission or is n...
It is common sense not to store passwords/credentials into SCM. I would like to know then what would be a good strategy for storing passwords/credentials in the context of continuous delivery. Where and how do I store credentials? How do I retrieve and use those credentials/passwords?
I am currently looking into Google Caja to run user-supplied JS code in the browser and in Node. So far, I understand, that, in a browser context, "cajoled code" disallows reading and messing with the window state by running unsafe code through a full-blown parser that gets rid of all kinds of attack vectors, and then ...
I am using a very primitive Java that doesn't have Generics, and also I can't use reflection. I want to create a generic list so it would be typed safe (i.e. I only have a list that contains Objects and I want to create a list that contains specific object and not a mix). On the other hand I also don't want to create a...
I'm currently reading 'Head first design patterns' and I already have a few questions on the first chapter of the book. This chapter introduces the 'prefer composition over inheritance' design principle, by explaining the 'Strategy-Pattern'. My question isn't about the pattern, but rather about a more basic design deci...
I was reading a lecture on arrays for Fortran 90 and I came across this sentence : 'Fortran always stores by columns - the first subscript varies more rapidly than the second, and so on.' What does the author mean to say ?
I'm learning about the Dependency Inversion Principle. It states that: High level modules should not depend upon low-level modules. Both should depend upon abstractions. For a while I tried to understand what it means that both the high level components and the low level components, rely on the abstractions and are...
On this site hackfind.com the autor put minified version of my library without any copyright notice. Is this violation of the LGPL. Note that using on a site is not a copy.
I am confused with what's the different between clarify and gather. I know using interview, observe or questionnaire can to elicit the requirement we want, but how to clarify the functional requirement?
I'm wondering what the difference is, and at what stage these different terms are used within the Agile/Scrum methodology? use case, user requirements and user stories Am I right in thinking they start off in the requirement elicitation stage as use cases then become the user requirements, which are pretty much the sam...
As far as I can see there are two ways of building a html page: "inside" the language (I'll call it building for lack of a better name) or outside the language (using templates). Let me explain a bit what I mean by this before I jump to the questions. Building One way is to build the html page "inside" the language you...
I am very confused about white box testing. A simplified version of the example: the entire system consists of three methods - methodA(), methodB(), methodC(). The program starts from methodA(), and methodB() requires input from methodA() and methodC() requires input from methodB(). Do we create 3 white box tests, one ...
I'm currently working on a project with a team that's using a git workflow. It's fairly simple: master should be in a deployable state and branches are used to create features and hotfixes. Whenever we have a feature or bugfix completed and tested then we move that over to master as soon as we can. The idea is that bra...
I am wondering if there are patterns, references or useful resources about how to implement objects that may have several equivalent representations. For example: Suppose I want to implement a Rectangle, and I will instantiate it using its length and width: class Rectangle: def __init__(self, length, width): ...
(I'm specifying this is a desktop application so people wouldn't refer specifically to web implementations of MVC). The title says it all pretty much. In an MVC structure - can the View ever hold a reference to the Model? Or should the Controller be used as a 'middleman' for communication between the View and Model - a...
Classes have 10-20 links with one another and you can't see anything in that mess of a diagram Unfortunately we finished coding already and if we change the class diagram we have to redo the whole thing
In my program, I have several class variables whose access specifier is known as private package. The default accessor specifier in Java is known as private package where it is accessible within the package which the class belongs to. For the UML class diagram , should I label these variables as public or private? I ...
To keep our house in order, I want to automatically assemble licenses for project dependencies in our documentation, rather than having to add them manually. Does anybody know a simple way to traverse programmatically a set of CSPROJ files and extract the license information for the referenced packages as a link or str...
According to Microsoft documentation, the Wikipedia SOLID principe article, or most IT architects we must ensure that each class has only one responsibility. I would like to know why, because if everybody seems to agree with this rule nobody seems to agree about the reasons of this rule. Some cite better maintenance, s...
Is there a specific term to call the process of modifying hard-coded codes into soft-coded codes? I have to report what I am doing to the Project manager, shall I just put "modifying hard-coded codes into soft-coded codes"? Example of "hard-coded codes" int random(){ return 42; } Example of "soft-coded codes" int rand...
We have quite a lot of places in the source code of our application , where one class has many methods with same names and different parameters. Those methods always have all the parameters of a 'previous' method plus one more. It's a result of long evolution (legacy code) and this thinking (I believe): "There is a met...
Correct me if I'm misunderstanding. Refer to the following sentence: Stack Overflow copied a key part of the Wikipedia database design. This turned out to be a mistake which will need massive and painful database refactoring to fix. The refactorings will be to avoid excessive joins in a lot of key queries. This ...
I am not quite sure, how to name my problem. But I will start with how I usually used git. I am working as a single developer on one git repository. Usually I make feature-branches from master, and merge them back into master, when the feature is finished. When meanwhile another feature-branch was merged into master, I...
In exercise 1-16 in The C Programming Language (K & R) it asks for us to: revise the main routine of the longest-line program so it will correctly print the length of arbitrary long input lines, and as much as possible of the text. From what I read here, I get the notion that the main routine is everything inside of ma...
Here's the situation: I have a "common" Data Access assembly that contains classes used in all my projects. Some of those are abstract classes that are only implemented by my data access layers for each project. In my projects I have a layered approach - separated data access, business layer, and UI. My data access ...
When you are working on a feature that depends on time... How do you organize unit testing ? When your unit tests scenarios depend on the way your program interprets "now", how do you set them up ? Second Edit: After a Couple of days reading your experience I can see that the techniques to deal with this situation usua...
From value point of view I see two groups of unit tests in my practice: Tests that test some non-trivial logic. Writing them (either before implementation or after) reveals some problems/potential bugs and helps to be confident in case logic is changed in the future. Tests that test some very trivial logic. Those test...
I am using redmine for project management and issue tracking. I was looking at the database tables and the underlying structure and was wondering if anyone who is experienced with database architecture can comment on the structure. I am concerned that once there are many users and hundreds (or thousands) of projects (e...
1 - Design my entities, ie (in python): class Account: def __init__(name, author): self.name = name self.email = email 2 - Design my repositories: (as interface) class AccountRepository: def add(self, account): """ @type account Account """ pass def find_by_name(self, name)...
I've just begun reading "The Art Of Unit Testing" by Roy Osherove, and while I'm mostly finding the material very helpful, he makes a statement about not using messages in your Assert statements. "Please never, ever, use this parameter. Just make sure your test name explains what's supposed to happen." My question...
Are closures considered impure in functional programming? It seems one can generally avoid closures by passing values directly to a function. Therefore should closures be avoided where possible? If they are impure, and I am correct in stating that they can be avoided, why do so many functional programming languages sup...
Ruby object has method/property: def tentakles_count 8 end JavaScript object has key/property: { justEnough: true } Now, when JavaScript gets serialised ruby object via XHR or WebSocket, developer has to use alien naming convention to access tentacles_count. The same goes for Ruby, when it gets json object POSTed, ...
I've been thinking about trying to get through the SICP again, this time well-armed with a better idea of what the SICP is meant to accomplish, and being older and wiser than my first attempt back in university. I've been told by old hands that the MIT Scheme is the only scheme I should think about using, and that oth...
I like both but I notice languages that use camelCasing for members sometimes need more adjustments when you want to edit your code. For example (in Python): node.customData() vs node.setCustomData() custom changes casing. It could be avoided if it was: node.getCustomData() In C# they will use PascalCasing for examp...
In basic networking, we talk about DNS servers, that they resolve human readable addresses (www.google.com) into an actual IP address. As far as I understand, at least using the basics, an IP address refers to a single device (say a router). Surely, www.google.com cannot be served up by one computer? How is www.google....
I've always thought that in typical MVC design it is bad practice to build & concatenate HTML strings in any PHP file or class that isn't strictly a template. I'm working on a large project with strict guidelines in place, and while it is forbidden to put any HTML code in the PHP controller, it is fair game to have PH...
I wonder why frameworks/libraries have their own helpers although they exist natively already. Let's take jQuery and AngularJS. They have their own each iterator functions: jQuery.each() angular.forEach() But we have Array.prototype.forEach. Similarly, jQuery.parseJSON() angular.fromJson() But we have the JSON.pars...
Could you tell me what is the goal of the MVVM pattern? What are the arguments or the reasons I can give to a team and product owner to respect and develop according to this pattern? I would like a simple answer. Something in one sentence or one word. Is it for maintenance security testing something else?
In our company we have a relatively long history of database backed applications, but have only just begun experimenting with dependency injection. I am looking for advice about how to convert our existing data access pattern into one more suited for dependency injection. Some specific questions: Do you create one acce...
According to DDD-principles I use factory-methods to create consistent objects and to ensure that the objects are in the right state. Now I'm in doubt about inner logic of setter methods. I'm tied up with an object, that's similar to the following code snippet, so let's take it as an example: public class UserCredentia...
I am self taught web developer. I do not have any computer science degree from university. I know HTML5, CSS3, Javascript, PHP and some Python. But I am having difficulties about being efficient. When I create a project, I am buried into files, folders, bugs and todoes. Because I am managing multiple projects at a time...
Two different teams (from different companies) are uniting to work on a communal open-source project. Agreeing on technical design is something we have no trouble with, but I'm struggling with tooling/workflow problems. I really like a BDD testing tool called phpspec (analogous to RSpec), whilst a lot of my teammates s...
In my domain I have an Account object. e.g. class Account { public string Number; public string SortCode; } Within the context of DDD, should this account object have an ID property? The ID would be a primary key, basically a database artefact.
I'm using a piece of commercial software where the server will reject any attempt to connect to it from a newer client. In other words, you can use version 8 of the client to connect to a v10.0 server, but not version 10.1 of the client. Obviously, this software is what it is. But why would it be designed that way? ...
Please consider a program with four classes: Class A, B, C and D. Classes A and B are subclasses of abstract super-class C. Class D is dependent on C. Meaning: It holds a C objectOfTypeC field. As we know, polymorphically the objectOfTypeC reference may hold objects of classד A and B. The value of this reference may ch...