DDD: Domain Model Factory Design

I am trying to understand how and where to implement domain model factories. I have included my `Company` aggregate as a demo of how I have done it. I have included my design decisions at the end - I would appreciate any comments, suggestions, critique on those points. **The`Company` domain model:**               public class Company : DomainEntity, IAggregateRoot     {         private string name;         public string Name         {             get             {                 return name;             }             private set             {                 if (String.IsNullOrWhiteSpace(value))                 {                     throw new ArgumentOutOfRangeException("Company name cannot be an empty value");                 }                      name = value;             }         }              internal Company(int id, string name)         {             Name = name;         }     }      **The`CompanyFactory` domain factory:** This class is used to ensure that business rules and invariants are not violated when creating new instances of domain models. It would reside in the domain layer.               public class CompanyFactory     {         protected IIdentityFactory<int> IdentityFactory { get; set; }              public CompanyFactory(IIdentityFactory<int> identityFactory)         {             IdentityFactory = identityFactory;         }              public Company CreateNew(string name)         {             var id = IdentityFactory.GenerateIdentity();                  return new Company(id, name);         }              public Company CreateExisting(int id, string name)         {             return new Company(id, name);         }     }      **The`CompanyMapper` entity mapper:** This class is used to map between rich domain models and Entity Framework data entities. It would reside in infrastructure layers.               public class CompanyMapper : IEntityMapper<Company, CompanyTable>     {         private CompanyFactory factory;              public CompanyMapper(CompanyFactory companyFactory)         {             factory = companyFactory;         }              public Company MapFrom(CompanyTable dataEntity)         {             return DomainEntityFactory.CreateExisting(dataEntity.Id, dataEntity.Name);         }              public CompanyTable MapFrom(Company domainEntity)         {             return new CompanyTable()             {                 Id = domainEntity.Id,                 Name = domainEntity.Name             };         }     }        1. The `Company` constructor is declared as `internal`.   **Reason:** Only the factory should call this constructor. `internal` ensures that no other layers can instantiate it (layers are separated by VS projects).   2. The `CompanyFactory.CreateNew(string name)` method would be used when creating a new company in the system.   **Reason:** Since it would not have been persisted yet, an new unique identity will need to be generated for it (using the `IIdentityFactory`).   3. The `CompanyFactory.CreateExisting(int id, string name)` method will be used by the `CompanyRepository` when retrieving items from the database.   **Reason:** The model would already have identity, so this would need to be supplied to the factory.   4. The `CompanyMapper.MapFrom(CompanyTable dataEntity)` will be used by the `CompanyRepository` when retrieving data from persistence.   **Reason:** Here Entity Framework data entities need to be mapped into domain models. The `CompanyFactory` will be used to create the domain model to ensure that business rules are satisfied.   5. The `CompanyMapper.MapFrom(Company domainEntity)` will be used by the `CompanyRepository` when adding or updating models to persistence.   **Reason:** Domain models need to be mapped straight onto data entity properties so that Entity Framework can recognise what changes to make in the database. Thanks


How to solve this problem- Neural Net? Fuzzy? Other?

Hi I have a programming problem that I would like to solve using some artificial intelligence technique. I really dont know where to start. I would like some guidance as to what methodology to pursue. Lets say I have 10,000 images of random people, and I need to detect elderly people in images. I might have algorithms like wrinkle detector, glasses detector, walking cane detector, missing teeth detector, skateboard detector, Playstation detector, etc. Each algorithm does a scan independently and outputs a number from 0 to 10 on the likelihood it thinks the image contains that item. Lets assume that works. There might be 100 different algorithms. My set of 10,000 images would be divided by a human into two groups, those that contain an elderly person, and those that do not. Now I need to develop a system that takes the series of values from the algorithm modules, when given an image to analyze, and calculates a single value that represents the likelihood that an image has elderly people in it or not. During training I would like it to be able to automatically build rules by analyzing all the algorithms' outputs. For example:   * If wrinkle detector, glasses detector, walking cane detector and missing teeth detector all output a high number, then output a high number.   * If wrinkle, glasses, cane and teeth detectors are high, but playstation and skateboard detectors are also high, then output is neither low nor high.   * hands detector and clothes detector should be essentially ignored as old and young people both have those (hopefully) What type of technology should I be implementing for the automated rule building system? Is this better solved by a neural network system? A fuzzy logic system? Something else? Thanks for any advice.


Scrum: Writing the time it took to complete a task

In my organization when we move a task to the "Done" column we write the number of hours it took to complete the task. It can be useful when during retrospective the team tries to understand why certain stories took longer to implement than anticipated. However it is also burdensome and developers feel somewhat micromanaged or stressed when they have to do this. What do you do in your teams? What do you recommend?


When practicing collective code ownership, can there be experts of each component?

Consider a complex and extensive software component; for example a multi- language text rendering engine, an IPC framework, a scheduler that can handle multiple time zones, a module full of complexities caused by the need to stay backwards compatible, etc... It requires a lot of knowledge of the details to maintain and extend such a component without introducing bugs with every code change. It is also often helpful to know the bug history when receiving a new bug report. Moreover, it requires thorough knowledge about the component's design to be able to maintain its consistency after future extensions, and it is good to know the rationale behind past design decisions. You might try to document this kind of knowledge, but it would require a lot of time and effort, it would rapidly become outdated and hence untrustworthy. Worse, everybody would still need to keep that written documentation in his/her mind. It seems to me that for such components, it is best to have someone that has in-depth knowledge, as one cannot thoroughly know and keep up with the code produced by a whole group of people without an excessive communication and learning overhead. I wonder whether the practice of collective code ownership allows for such experts, as it seems to me that it would require some kind of "weak code ownership". And if not: how can it succeed without a massive amount of duplicate work?


Pattern to use to relate multiple data sources to different user data widgets

I have an client x server intranet application the basically gets data from the server, format it and send that data to the client for display. At the server we are using ASP.NET C# running on IIS and at the client we have Javascript widgets. The client x server requests are done through ajax calls. I have lots (100+) of server objects, that can be shown into 10 different formats in the browser though different graphical widgets. So, basically we have the following structure: ![enter image description here](http://i.stack.imgur.com/JJLxc.png) So, for every server object I need, at nnnWidgetDataGetter objects, to do some data transformation to widget data format to be sent to the client. Every widget can request data from all objects of the server. Using a normal approach, I would have to write tons of methods, one for each server basic class times each datagetter class. To avoid writing hundred of methods with similar behaviour, we decided to use a dynamic approach at the DataGetter classes (static classes), where the business object is evaluated at runtime, data is gathered from this object, formatted and sent to the client. The problem is that using dynamic object creation and invokation we loose the Intellisense, so the code is turning very big and difficult to understand and maintain. After a while we found out that we´re not using the correct approach and started thinking about sw patters that would help us solve this. So we are looking for the correct pattern to solve this issue that would keep a typed structure where Intellisense could work and that avoid us to write hundred of different methods. We appreciate very much any kind of help.


How to route messages between clients using a central server in Python

I've got three Raspberry Pis sitting around. I want 2 of them to be able to chat while the 3rd routes the messages (acts as a server between them). The general flow of events should be something like this:   * Server starts running on Pi #1   * Pi #2 starts running and connects to the server (who's IP will be static I guess) with a name he chooses. Pi #3 does the same as #2.   * Pi #3 can then, knowing the name of Pi #2, send a message to Pi #2 using ... something. This is the general outline of what I want to achieve. I'm not sure what the server that runs on Pi #1 should be (I've heard of webserver frameworks like Flask but I don't have enough knowledge to determine if they fit my needs). I'm also not sure on what I should be using for the client side (Pi #2,3). I could probably use sockets but I assume there is a better / easier way.


Do software licenses (ie, MIT) need to be included with the executable?

Whenever a software license reads: `... The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.` Does this mean you have to include it with the executable (the version customers get) or just the source code (for the programmers)? Sorry if this is a silly question, but it doesn't clearly state what "the Software" is referring to, and I can see people maybe wanting credit for it. If you don't have to include the license with the executable, do you need to give credit in your executable release some other way, like some other kind of copyright notice that just says "Copyright "? Is there a specific format to that?


Range searching with WebGL

Is it possible to use somehow WebGL to fasten up 1d range searching? I need to find overlapping date intervals, and I thought that 3d games usually have a very similar problem by rendering frames... _I read ofinterval trees as an alternative if this idea does not work, but I am open for suggestions...   Btw. if stackoverflow would be a better place for this question, pls let me know!_


Liskov substitution and abstract classes / strategy pattern

I'm trying to follow LSP in practical programming. And I wonder if different constructors of subclasses violate it. It would be great to hear an explanation instead of just yes/no. Thanks much! P.S. If the answer is `no`, how do I make different strategies with different input without violating LSP?               class IStrategy     {         public:             virtual void use() = 0;     };          class FooStrategy : public IStrategy     {         public:             FooStrategy(A a, B b) { c = /* some operations with a, b */ }             virtual void use() { std::cout << c; }         private:             C c;     };          class BarStrategy : public IStrategy     {         public:             BarStrategy(D d, E e) { f = /* some operations with d, e */ }             virtual void use() { std::cout << f; }         private:             F f;     };


How to store Role Based Access rights in web application?

Currently working on a web based CRM type system that deals with various Modules such as Companies, Contacts, Projects, Sub Projects, etc. A typical CRM type system (asp.net web form, C#, SQL Server backend). We plan to implement role based security so that basically a user can have one or more roles. Roles would be broken down by first the module type such as: -Company -Contact And then by the actions for that module for instance each module would end up with a table such as this:               Role1 Example:              Module   Create  Edit        Delete   View         Company   Yes    Owner Only    No     Yes         Contact   Yes    Yes           Yes    Yes      In the above case `Role1` has two module types (Company, and Contact). For company, the person assigned to this role can create companies, can view companies, can only edit records he/she created and cannot delete. For this same role for the module contact this user can create contacts, edit contacts, delete contacts, and view contacts (full rights basically). I am wondering is it best upon coming into the system to session the user's role with something like a: `List<Role> roles;` Where the `Role` class would have some sort of `List<Module> modules;` (can contain Company, Contact, etc.).? Something to the effect of:               class Role{     string name;     string desc;     List<Module> modules;     }      And the module action class would have a set of actions (Create, Edit, Delete, etc.) for each module:               class ModuleActions{     List<Action> actions;     }      And the action has a value of whether the user can perform the right:               class Action{     string right;     }      Just a rough idea, I know the action could be an enum and the ModuleAction can probably be eliminated with a `List<x, y>`. My main question is what would be the best way to store this information in this type of application: Should I store it in the User Session state (I have a session class where I manage things related to the user). I generally load this during the initial loading of the application (global.asax). I can simply tack onto this session. Or should this be loaded at the page load event of each module (page load of company etc..). I eventually need to be able to hide / unhide various buttons / divs based on the user's role and that is what got me thinking to load this via session. Any examples or points would be great.


Android From Local DB (DAO) to Server sync (JSON) - Design issue

I sync data between my local DB and a Server. I'm looking for the cleanest way to modelise all of this. I have a com.something.db package That contains a Data Helper and couple of DAO classes that represents objects stored in the db (I didn't write that part)               com.something.db     --public DataHelper     --public Employee              @DatabaseField e.g. "name" will be an actual column name in the DB              -name              @DatabaseField              -salary              etc... (all in all 50 fields)      I have a com.something.sync package That contains all the implementation detail on how to send data to the server. It boils down to a ConnectionManager that is fed by different classes that implements a 'Request' interface               com.something.sync     --public interface ConnectionManager     --package ConnectionManagerImpl     --public interface Request     --package LoginRequest     --package GetEmployeesRequest      My issue is, at some point in the sync process, I have to JSONise and de- JSONise my data (E.g. the Employee class). But I really don't feel like having the same Employee class be responsible for both his JSONisation and his actual representation inside the local database. It really doesn't feel right, because I carefully decoupled the rest, I am only stuck on this JSON thing. What should I do ? Should I write 3 Employee classes ?               EmployeeDB        @DatabaseField e.g. "name" will be an actual column name in the DB        -name        @DatabaseField        -salary        -etc... 50 fields               EmployeeInterface        -getName        -getSalary        -etc... 50 fields               EmployeeJSON        -JSON_KEY_NAME = "name"   The JSON key happens to be the same as the table name, but it isn't requirement        -name        -JSON_KEY_SALARY = "salary"        -salary        -etc... 50 fields      It feels like a lot of duplicates. Is there a common pattern I can use there ?


Reasonable Number of Directed Graph Nodes and Edges

How many directed graph nodes are typically represented in the browser? I'm working with some large data-sets with nodes and edges more then 400,000. I'm wondering if I am going down a fruitless path trying to represent them in the browser via arbor.js or similar JS libraries. What's the most effective way to allow a large number(large relative to my domain of real estate transactions, maybe 1-10,000) of users to visualize and browse a large directed graph of up to 500,000 records?


I don't understand why algorithms are so special

I'm a student of computer science trying to soak up as much information on the topic as I can during my free time. I keep returning to algorithms time and again in various formats (online course, book, web tutorial), but the concept fails to sustain my attention. I just don't understand: why are algorithms so special? I can tell you why fractals are awesome, why the golden ratio is awesome, why origami is awesome and scientific applications of all the above. Heck I even love Newton's laws and conical sections. But when it comes to algorithms, I'm just not astounded. They are not insightful in new ways about human cognition at all. I was expecting algorithms to be shattering preconceptions and mind- altering, but time and time again they fail miserably. Perhaps I am doing something wrong in my approach. Can someone tell me why algorithms are so important to programming?


Should you make private properties?

private string mWhatever;          private string Whatever     {         get         {             return this.mWhatever;         }         set         {             this.mWhatever = value;         }     }      I've seen some people who make properties for every single member, private or not... does this make any sense? I could see it making sense in 1% of the cases at times when you want to control access to the member inside the class containing it because if you didn't use properties for every member it would lead to inconsistencies and checking to see if the member has an access or not (since you have access to both in the scope of the class).


Best practices for constants

How do you guys handle constants, especially in Java (static final) and C++ (define)?   * Do you use dedicated headers (C++) or classes (Java) for all constants?   * Do you turn all literal values into constants or just those you want to use in multiple places? This is probably a bit subjective, so I'm especially interested in the reasons for your approach.


Modeling a Student Application/Committee Relationship

I'm developing an ERD for a graduate student manager program (it's for a university class, so it's a fairly trivial implementation). In this snippet of the model, I'm trying to work out the 'application' and 'committee' entities/relationships. Basically, a committee - comprised of staff members - can be formed and assigned to review an application. Here are the entities I've come up with:   * **application:** Comprised of a student's application data submitted through a form (student id, date submitted, degree, etc.).   * **committee:** Self-explanatory. Group of staff members that can review applications.   * **staff_member:** Any faculty member.   * **committee_membership:** An associative entity I've created to resolve the many-to-many relationship between committee and staff member since a committee can have many staff members, and a staff member can belong to many committees.  Is this an effective implementation of what I'm trying to do? I'm still trying to wrap my head around associative entities and when they are needed. It seems strange to have the 'committee' table with a single column. Also - and I know I've given you limited information - do my relationships look generally correct? ![enter image description here](http://i.stack.imgur.com/6fo25.png)


How does datomic handle "corrections"?

**tl;dr**   * Rich Hickey describes datomic as a system which implicitly deals with timestamps associated with data storage   * from my experience, data is often imperfectly stored in systems, and on many occasions needs to retroactively be corrected (ie, often the question of "was a True on Tuesday at 12:00pm?" will have an incorrect answer stored in the database) This seems like a spot where the abstractions behind datomic might break - do they? If they don't, how does the system handle such corrections? * * * Rich Hickey, in several of his talks, justifies the creation of datomic, and explains its benefits. His work, if I understand correctly, is motivated by core the insight that humans, when speaking about data and facts, implicitly associate some of the related context into their work(a date-time). By pushing the work required to manage the implicit date-time component of context into the database, he's created a system which is both much easier to understand, and much easier to program. This turns out to be relevant to most database programmers in practice - his work saves everyone a lot of time managing complex, hard to produce/debug/fix, time queries. However, especially in large databases, data is often damaged/incorrect (maybe it was not input correctly, maybe it eroded over time, etc...). While most database updates are insertions of new facts, and should indeed be treated that way, a non-trivial subset of the work required to manage time-queries has to do with retroactive updates. I have yet to see any documentation which explains how such corrections, or retroactive updates, are handled by datomic; from my experience, they are a non-trivial (and incredibly difficult to deal with) subset of time-related data manipulation that database programmers are faced with. Does datomic gracefully handle such updates? If so, how?


Password reset process

So I'm working on my first password reset mechanism. I'm going with what I understand to be a fairly common procedure:   1. User clicks "Forgot Password"   2. User is prompted for email address   3. If the entered email address is valid, send an email with a reset link to it   4. Reset link uses a token of some kind to identify the user account and keep its details secure   5. When password is reset, generate a new token and save it to the user account I feel like this should be pretty secure, but I was wondering if anyone could provide any insights that I may not be considering at this point.


A good name for ValueObject that contains database update/create column values

We all know these fields, database admins so like to add:   * UserCreated & DateCreated   * UserUpdated & DateUpdated They need to be displayed in the UI so I want to put them in some `ValueObject` but I can't come up with a good name to call the class...


Builder Pattern: When to fail?

When implementing the Builder Pattern, I often find myself confused with when to let building fail and I even manage to take different stands on the matter every few days. First some explanation:   * With _failing early_ I mean that building an object should fail as soon as an invalid parameter is passed in. So inside the `SomeObjectBuilder`.   * With _failing late_ I mean that building an object only can fail on the `build()` call that implicitely calls a constructor of the object to be built. Then some arguments:   * In favor of failing late: A builder class should be no more than a class that simply holds values. Moreover, it leads to less code duplication.   * In favor of failing early: A general approach in software programming is that you want to detect issues as early as possible and therefore the most logical place to check would be in the builder class' constructor, 'setters' and ultimately in the build method. What is the general concensus about this?


Best way to reuse common functions between ASPX pages ?

I have a bunch of functions that are used across multiple ASPX files. I want to condense these down to one file to be used for all the ASPX files. I have a few ideas but I want to know what the accepted method to doing this would be. I have an idea to just create a class to put them in. However, I was wondering if i could put them in a ascx page, but that does not look like the solution I'm looking for. Is there a accepted method for this type of situation?


Sports Programming

Other than programming, I'm addicted to sports. I'd like to integrate the two together. What are different programming languages that companies like ESPN use to work with stats? What techniques are used to do this, and how can I get going with it myself?


Does the ray tracing algorithm involves rasterization of image?

I am constructing a ray tracing algorithm , i know that the first step is to develop camera and view plane specifications. Now is the next step performing rasterization algorithm on image before a BVH tree is constructed so that intersection tests can be performed? Kindly Guide


How to structure a project that supports multiple versions of a service?

I'm hoping for some tips on creating a project (ASP.NET MVC, but I guess it doesn't really matter) against multiples versions of a service (in this case, actually multiple sets of WCF services). Right now, the web app uses only some of the services, but the eventual goal would be to use the features of all of the services. The code used to implement a service feature would likely be very similar between versions in most cases (but, of course, everything varies). So, how would you structure a project like this? Separate source control branches for each different version? Kind of shying away from this because I don't feel like branch merging should be something that we're going to be doing really often. Different project/solution files in the same branch? Could link the same shared projects easily Build some type of abstraction layer on top of the services, so that no matter what service is being used, it is the same to the web application?


What are the so-called "levels" of understanding multithreading?

I seem to remember reading somewhere some list of 4 "levels" of understanding multithreading. This _may_ have been in a formal publication, or it _may_ have been in an extremely informal context (even like in a Stack Overflow question, for example). Unfortunately I don't remember who referred to them or precisely what they were. I seem to recall that they were roughly like:   1. Total ignorance   2. Awareness mixed with incompetence   3. Relative competence mixed with fear   4. True understanding My intention is to refer to these levels in a blog post I'm writing, with a reference; but I can't for the life of me remember where I first encountered this list. Brief Google searches have proved unfruitful.


Using π, φ, λ etc. as variable names while programming?

This is a function in the d3.v3.js file (the graph library D3.js):                 function d3_geo_areaRingStart() {         var λ00, φ00, λ0, cosφ0, sinφ0;         d3_geo_area.point = function(λ, φ) {           d3_geo_area.point = nextPoint;           λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos(φ = (φ00 = φ) * d3_radians / 2 + π / 4),            sinφ0 = Math.sin(φ);         };         function nextPoint(λ, φ) {           λ *= d3_radians;           φ = φ * d3_radians / 2 + π / 4;           var dλ = λ - λ0, cosφ = Math.cos(φ), sinφ = Math.sin(φ), k = sinφ0 * sinφ, u = cosφ0 * cosφ + k * Math.cos(dλ), v = k * Math.sin(dλ);           d3_geo_areaRingSum.add(Math.atan2(v, u));           λ0 = λ, cosφ0 = cosφ, sinφ0 = sinφ;         }         d3_geo_area.lineEnd = function() {           nextPoint(λ00, φ00);         };       }      I was completely taken aback that the programmers used π, φ and λ as variable names. Surprisingly, these variables were accepted even by Notepad (ie: it didn't turn into junk/unrecognized characters).   Is it good practice to use such variables? I can see that they're very intuitive and searchable too, but a bit unnerving.


1-click software release

I am rewriting a vb6 installer into NSIS. One of my priorities is to compile- to-release in the least number of steps possible; ideally, a one click process, in which all needed files are included, registered, and put in the right folders. At the moment, I am creating several folders. One for app_path files, one for system_files, etc. So, every time that a file is modified or a new file added, I just drop it in the right folder and recompile. However, if a completely new file is included, steps like registering a DLL still need to be implemented in code. Any suggestion on how to improve this approach?, or on how to design a one- click compile-to-release process? EDIT: The original installer was created using the Package and Deployment wizard from Visual Basic 6.0. Every time that I need to release my software, I found my self updating and adding files, updating the respective lst file, and repackaging everything (CAB files, dlls, etc) into one exe in order to release it from our website. It is a cumbersome process. Additionally, due to pure design. The original software has been copy pasted in several projects, creating several application and its respective VB6 installers (repeating a lot of common files). Ideally, there would be one single installer, which allows the installation of the different executable and manages all the shared files among them.


What is the difference between `update` and `upgrade` in the context of application software?


Freedom of Speech vs. Computer Security

Over the Summer I found a cookie put on my computer by the school's network that seemed like it could be a problem. It stored authentication information and (long story short) I found if you put in other people's easily attainable information, you become signed in as them. Slow but sure, I discovered 3 security exploits that, when working together, compromised ALL security on the website. In theory I could sign in as teachers, access any student's email (with capabilities to send), adjust all grades, anything I wanted to do, I could do. They have since fixed this error, not only is the cookie gone, but the site is replaced with a Microsoft Sharepoint foundation instead of their "roll your own" system. I didn't research this to take advantage of the exploit. I did it because these exploits would allow MY information to be viewed by ANYBODY, a student of the school or not. So I went to my School's IT so that they would fix it. They did, and almost a month after they fixed, I decided to write a 2 page-ish article on my blog. I'd link to that page now except that the head of IT has asked that I take the page down. He claims we agreed that I'd never talk about the exploit to anybody outside of IT. I know I never agreed to that because since square one I wanted to take credit for my 3 or 4 weeks of hard investigation and work, I fully intended on telling people about the problem. I wrote my article with discretion. I never mentioned the school's name and it had very little subjective content, it was primarily how I found the exploits, what they were, and how they could be used. The idea was that if I talked about it from the point of view of the discoverer, it'd show insight into how to develop against it. The school was very appreciative that I did not use these exploits and that I came straight to them with the intention of fixing it. I only blog about Software Development concepts. Finding security holes in the wild like this is a perfect subject for my blog. Also, I want to make a name for myself in the cyber security world, Bruce Schneier linked me to an article in his blog talking about how if you want to make a name for yourself in the cyber security, you need to break ciphers, find security holes and fix them, and such. In short, I feel I deserve credit for the hard work I did, they feel that the school's image is more important even though the security hole is more than fixed. What's the best way to go about getting my credit here? I have posted a pseudo censored version in the mean time. UPDATE: no more pseudo censored version, I just put up a new article that's a little more ambiguous about it even being a school. New article can be found here.


What algorithm browsers follow to remember values for form controls?

You can have different HTML `input` elements on a single HTML `form` and all of them, have their associated remembered values (values that you've entered in those fields); Is it related to the `id` or `name` attribute of the `input` element? No. Proof? Your email address appears on many `input` elements across different websites, and all those fields have different `id` and `name` attributes. So, there is a mystery here I don't understand. How browsers remember values for HTML form controls? What is the algorithm? How they know that they should show your email on _this_ control and not on _that_ control, while controls are both HTML `input type=text` elements?


Difference between reverse lookup tables and rainbow tables

Using Reverse Lookup Tables, you create a lookup table consisting of the password hash of user accounts. Then you use another table which consists of hashes with guessed passwords. Then you compare the two to see if the hashed password of compromised user account matches hashed password in lookup table. Using Rainbow Tables, it appears to be the same technique except the lookup table is smaller so you can search through them quicker. What is the real difference between reverse lookup tables and rainbow tables?


What is the term that means "keeping the arguments for different API calls as similar as possible"?

There is a word which I can never remember... it expresses a design goal that API calls (or functions or methods or whatever) should be as similar as reasonably possible in their argument patterns. It may also extend to naming as well. In other words, all other things being equal, it is probably bad to have these three functions:               deleteUser(email)     petRemove(petId,species)     destroyPlanet(planetName,starName)      if instead you could have               deleteUser(userId)     deletePet(petId)     deletePlanet(planetId)      What is the word for this concept? I keep thinking it's "orthogonal" but it definitely isn't. Its a very important concept, and to me it's one of the biggest things that makes some APIs a joy to work with (because once you learn a few things you can pretty much use everything without looking at doco), and others a pain (because every function is done inconsistently).


Are all programming problems algorithm problems?

I like how "Introduction to Algorithms" by Cormen et al. conveys knowledge. One reason is that everything has to do with programming problems and the book is not implemented in any particular programming language. This language independency provides focus on the ideas in general. So my question is, as it says in the title. Is every solveable programming problem solveable by thinking in this algorithmic fashion. No matter which language, field, etc ? If yes, give arguments, else, give arguments! I have not implemeted many complex programs with GUI, AI, Graphics, etc ... But are these types of problems also a matter of thinking out good algorithms?


Use of versioned objects/data to handle program version compatibility?

Is there a common name for the practice of keeping a version number on your data, so that different versions of your program can identify, for example, "current", "legacy", and "too-old-to-deal-with" versions of the same type of object? As discussed here: Strategy for backwards compatibility of persistent storage.


Is there canonical jUnit reference documentation?

I can't seem to find any kind of complete reference for jUnit. The only way I've managed to find to know about all the features in jUnit is to check out all the release notes for it. For example there is no mention of @Rules in the official page unless you count the blog posts. But for that you first need to know a feature exists to search for it. Is there a canonical reference for jUnit? What's the best method for learning about jUnit features? What I've tried:   * jUnit Cookbook \- Really basic, very few features covered   * The official FAQ \- Covers more but it doesn't have @Rules or anything covered there. Updated last time in 2006


Who should control navigation in an MVVM application?

Example #1: I have a view displayed in my MVVM application (let's use Silverlight for the purposes of the discussion) and I click on a button that should take me to a new page. Example #2: That same view has another button that, when clicked, should open up a details view in a child window (dialog). We know that there will be Command objects exposed by our ViewModel bound to the buttons with methods that respond to the user's click. But, what then? How do we complete the action? Even if we use a so-called NavigationService, what are we telling it? To be more specific, in a traditional View-first model (like URL-based navigation schemes such as on the web or the SL built-in navigation framework) the Command objects would have to know what View to display next. That seems to cross the line when it comes to the separation of concerns promoted by the pattern. On the other hand, if the button wasn't wired to a Command object and behaved like a hyperlink, the navigation rules could be defined in the markup. But do we want the Views to control application flow and isn't navigation just another type of business logic? (I can say yes in some cases and no in others.) To me, the utopian implementation of the MVVM pattern (and I've heard others profess this) would be to have the ViewModel wired in such a way that the application can run headless (i.e. no Views). This provides the most surface area for code-based testing and makes the Views a true skin on the application. And my ViewModel shouldn't care if it displayed in the main window, a floating panel or a child window, should it? According to this apprach, it is up to some other mechanism at runtime to 'bind' what View should be displayed for each ViewModel. But what if we want to share a View with multiple ViewModels or vice versa? So given the need to manage the View-ViewModel relationship so we know what to display when along with the need to navigate between views, including displaying child windows / dialogs, how do we truly accomplish this in the MVVM pattern?


Semantic coupling vs. large class

I have hardware I communicate with via TCP. This hardware accepts ~40 different commands/requests with about 20 different responses. I've created a HardwareProxy class which _has a_ TcpClient to send and receive data. I didn't like the idea of having 40 different methods to send the commands/requests, so I started down the path of having a single SendCommand method which takes an ICommand and returns an IResponse, this results in 40 different SpecificCommand classes. The problem is this requires semantic coupling, i.e. the method that invokes SendCommand receives an IResponse which it has to downcast to SpecificResponse, I use a future map which I believe ensures the appropriate SpecificResponse, but I get the impression this code smells. Besides the semantic coupling, ICommand and IResponse are essentially empty abstract classes (Marker Interfaces) and this seems suspicious to me. If I go with the 40 methods I don't think I have broken the single responisbility principle as the responsibility of the HardwareProxy class is to act as the hardware, which has all of these commands. This route is just ugly, plus I'd like to have Asynchronous versions, so there'd be about 80 methods. Is it better to bite the bullet and have a large class, accept the coupling and MarkerInterfaces for a smaller soultuion, or am I missing a better way? Thanks. ## Possible Solution Based on DXM's response this is what I came up with:               struct Proxy     {        template<class C, class R>        ICommand<C, R>* CreateCommand()        {           return new C(this);        }             void Send(std::string s)        {           //tcp send here for now print command name           cout << s << endl;        }     };          template<class Derived>     struct IResponse     {};          struct DerivedResponse1 : IResponse<DerivedResponse1>     {        std::string GetValue()        {           return "DerivedResponse1";        }     };          template<class Derived, class Response>     struct ICommand     {     protected:        Proxy* pProxy;     public:        Response* Send()        {           std::string msg = "Sent: " + static_cast<Derived*> (this)->GetName();           pProxy->Send(msg);           //wait for future here           Response* pResponse = new Response; //replace with future value           return pResponse;        }     };          struct DerivedCommand1 : public ICommand<DerivedCommand1, DerivedResponse1>     {        DerivedCommand1(Proxy* pProxy)        {           this->pProxy = pProxy;        }             std::string GetName()        {            return "DerivedCommand1";        }     };          int main()     {        Proxy proxy;             ICommand<DerivedCommand1, DerivedResponse1>* pDerivedCommand =                 proxy.CreateCommand<DerivedCommand1, DerivedResponse1>();        DerivedResponse1* pDerivedResponse = pDerivedCommand->Send();        cout << "Received :" << pDerivedResponse->GetValue() << endl;             return 0;     }      How does that look? It seems like I may not even need the IResponse interface, we'll have to see when I implment it. I realize there is a lot of important stuff missing, like the futures, but I wanted to get the template stuff down first. What do you think of passing in the proxy to the command? Also what about having the send in the ICommand as opposed to writting it for every command? Am I violating any other OO principles? Thanks.


Coding user rights

Imagine a system which has a number of functions and a number of users. A user must have rights to a specific function. Users may belong to a group. A group may belong to a group. So as a simple illustration, user A has rights to function 1 and 2. User b has rights to function 2 and 3. User A is in group1 which has rights to function 3, but negative, i.e. explicit denied access to function 1. For extra complexity, perhaps the function has default rights. So you can say, but default everyone has access to function a, or no one has access to function a. I guess it's the same as having an Everybody group. So the question is how are you managing user rights? Do you make all rights additive? Do you allow the explicit denied I mention at the end? Do you have a system where the most access possible is granted or the least? Do you make user rights trump group rights, or vice versa? I've seen a number of variations for applying rights. I'm now defining my own and I'm really looking for any experience you have in that area where you wish you'd done something different, or were delighted you chose a particular way of doing things. Thanks


How to become a professional web developer from a C/C++ programmer?

I am currently a high school student and know how to use Pascal and C/C++ to take part in competitions such as the Informatics Olympiad. I have learned data structures and many algorithms to solve various kinds of problems. Now, I want to move on to become a web developer. However, I know web development is quite different from competitive programming. To make a web application, I have to master HTML, databases, back-end programming etc. But these all look like separate pieces of information. I don't know where to start and what order should I follow. Anybody who can give a comprehensive list of learning points? I know there are HTML, Ruby on Rails, CSS and Javascript. What else? More importantly, can someone give a brief outline of their relationship?


Are Django forms violating MVC?

I just started working with Django coming from years of Spring MVC and the forms implementation strikes as being slightly crazy. If you're not familiar, Django forms starts with a form model class that defines your fields. Spring similarly starts with a form-backing object. But where Spring provides a taglib for binding form elements to the backing object within your JSP, Django has form widgets tied directly to the model. There are default widgets where you can add style attributes to your fields to apply CSS or define completely custom widgets as new classes. It all goes in your python code. That seems nuts to me. First, you are putting information about your view directly in your model and secondly you are binding your model to a specific view. Am I missing something? EDIT: Some example code as requested. Django:               # Class defines the data associated with this form     class CommentForm(forms.Form):         # name is CharField and the argument tells Django to use a <input type="text">         # and add the CSS class "special" as an attribute. The kind of thing that should         # go in a template         name = forms.CharField(                     widget=forms.TextInput(attrs={'class':'special'}))         url = forms.URLField()         # Again, comment is <input type="text" size="40" /> even though input box size         # is a visual design constraint and not tied to the data model         comment = forms.CharField(                    widget=forms.TextInput(attrs={'size':'40'}))      Spring MVC:               public class User {         // Form class in this case is a POJO, passed to the template in the controller         private String firstName;         private String lastName;         get/setWhatever() {}     }               <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>          <form:form commandName="user">

                   First Name:	                                      <form:input path="firstName" class="special" />

                   Last Name:	                   <form:input path="lastName" size="40" />

                                          <input type="submit" value="Save Changes" />

       </form:form>


Delphi Build Server - Do I need to check in .dres files?

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 putting them in SVN though. For one thing, if they're needed by the build server then they're not being built by the build server and we're not really creating the build in one step since we're using pre-compiled code (I might as well just check in my DCU's, tear off my beard and return my Delphi-4-Ever allegiance card). I see in Delphi after compiling a project: ` c:\program files (x86)\embarcadero\rad studio\9.0\bin\cgrc.exe -c65001 "PROJResource.rc" -foPROJ.dres ` Those files are produced by brcc32 compiling an RC file. I'd say, well just add that line to the build server, but `PROJResource.rc` isn't in SVN either! `PROJResource.rc` is automatically generated by Delphi from adding things using the project manager and I never noticed it so I never added it to SVN and no one else complained (I think the .dproj file is behind this). The RC files that I wrote myself are in SVN though. So... what's the best way to fix this, just check in the PROJResource.rc or is there something else we can be doing to streamline this?


Transactional database and Datawarehouse on the same Postgresql cluster?

Is it conceptually feasible to have on a Postgresql Cluster a transactional database and at the same time a datawarehouse that would get feeded by the transactional database ?


How to be up to date with the LAMP platform?

Most of times I get to know about the new features too late. It is okay at least I know about them does not matter from where I know But I feel it is too late to know about those features. I am working on LAMP platform and I want to keep myself up to date with the new things, anything happening new with LAMP. Can you please let me know what resources should I use? What groups should I follow? From where I can get the latest updates about any activity, event and feature about LAMP?


Looking for an open source project in Python

I am looking for practical tasks to get experience with Python. Just reading the books and not doing any tasks in the language is not effective. I solved some problems on the Project Euler and TopCoder and it helped me to learn the syntax of the language better. But those tasks are hard algorithmically, but as a rule is quite simple from the point of view of programming. Now I'm looking for an interesting open source project in Python, participation in which will help me to better understand the OO-model of language. Although, this is my first step with Python, in general, I am an experienced programmer and I can be useful for a project. May be someone can suggest something?


What is detailed design? what are the advantage disadvantages using it?

Im really not getting the idea:   1. What is Detailed Design.   2. Why use Detailed Design.   3. Advantages/Disadvantage of using Detailed Design.   4. Any alternative methods other than using Detailed Design. Could some one please guide/explain me ?


What do I call people who extend my class in base class documentation?

Been calling them "implementers", but it seems weird to me.               /// <summary>     /// Implementers should implement this.  Derp     /// </summary>     protected abstract void InternalExecute();      A point of clarification, I'm interested in what to call the **people** who create child classes, not the child classes themselves. "Hey, you there" not "that thing there."


How to store multiple requirements with OR and AND?

Well I'm working on a personal project that needs to check if a user has met certain requirements, and they come in a form of Requirement: [c1 OR c2] AND [d1 OR d2] Requirement: [c1 AND c2] OR [d1 AND d2] Requirement: c1 AND any dn(n can be any integer) I'm just not sure how to store these sorts of requirements, I'm thinking of using another object to hold c1,c2,d1,d2....dn and OR, but that seems like a roundabout way of doing things. Is there a better method?


What is the best way to implement different views of one resource in RESTful manner?

Imagine, there is a resource, for example event. User is able to get list of events in HTML format. He should be able to view that list in two ways: as a list and as a calendar. How the API should respond to this options? The simplest approach, I think, is to pass some parameter to index action to determine which type of presentation to use, but I don't like it. Don't know why, it is not RESTful for me. What do you think, do I misunderstood something and should keep things simple or there is a better approach?


Where does Microsoft currently stand on dynamic languages?

With languages Python and Ruby still having a good foothold in the market what is Microsoft's current stance on dynamic languages? Does Microsoft have any plans to incorporate or invent it's own dynamic language?


Using a back-end mechanism to copy files to DB and notify the application

This Scenario: User copies large files to a local folder. I want to watch that folder and when a new file is dropped then go and copy it to Database, so later when coping is done I can actually use it in my application. ( A C# WinForms App). It would be awesome to also find a way to somehow get notified in the Application that hey copying the file to DB is finished and ready for use... I am using C#.net, Windows... What solutions/architecture do you suggest for this? For example having a windows service running all the time watching that folder, when something copied goes and write it to DB ... then how about getting notified? MSMQ is something I can use? don't know much about it yet. Thanks.


How do you manage projects left over by other employees?

It happens that some one just leaves the company all of sudden. Now his work needs to be completed and you are being assigned it. Having no idea what was he up to (was it 90% done or 9%), how do you manage the leftover?   1. Shall I start from scratch? What if it was 90% done?    2. Shall I try and understand whatever he has done? What if it was just nonsense?


Is my application secure enough

first of all, I don't have any code to display in my question here, because I'm still designing the application structure, so i only got design developed. I'm building a phone application that I'm trying to make as secure as possible, i know it's not that necessary on application that is the size of mine, but still, good practice. My app is on Angular with phonegap, server side is accessible through https and is nodejs with mongoDB, is a stateless server, restful api. Once the user is logged in (using user and password or facebook), a session id is stored on the client side (angular cookies) and is required with each access to the server (checking if there is a user logged in with that session id). I also heard about form tokens so i implanted that - On each form that in the end will send a request to the server (for example, changing user information and hitting save) it will also require a form token, random value that is generated for the session on building the form - onLoad function that calls the server to generate a specific form token. Seems pretty cool, but still not sure if it any good. By thinking of it, someone can call my restful method to generate any form token he wants using session id he found (by brute forcing or whatever), and then call any other restful method to change anything for that user.. also, my server should be limited to be accessed only from the application...can't restrict origin because the IP changes from phone to phone...what are the restriction my server should have? I am a starter at security for web apps and any advice, explaining and help would really help! is my application secure enough?


Why do Git/Mercurial repositories use less space?

I've read on several discussions here and on SO that DVCS repositories use about the same or less space than their centralised counter-parts. I may have missed it, but I haven't found a good explanation of why that is. Anyone know?


How to design a domain entity that uses a dependency to manage a state field?

I'm new to DDD and IOC/DI and I'm having some trouble figuring out how to design an entity that needs to use a state pattern to manage its status. As the transitions are somewhat complicated, I'm using a finite state machine (FSM) to handle the states (I'm using Stateless). To further complicate the situation, the FSM needs to be loosely coupled to an entity. I.e. while I know that the state of the entity must be handled by a FSM, I don't necessarily know exactly what the FSM is (i.e. the entity doesn't know what states/triggers/transitions it might go through). The users use the term workflow to define the FSM (state, triggers, transitions, rules etc). The workflow changes independently of the entity. They might want to add new states, change rules, triggers etc. independent of any changes to the entity. I'm handling this by dynamically loading an assembly that contains a definition of the FSM (which implements a known interface), then using a service that is injected into the entity, the entity calls the service and gets the FSM it is using. This involves potentially loading assemblies, caching the factory that creates the FSM and then assigning the FSM that is in the appropriate state to the entity. Finally, the FSM can return the set of valid triggers that can be provided to the UI so one of the those triggers can be selected and fired. The actual workflow in completely encapsulated externally to the entity. So, currently I'm my entity looks something like this:               public class EntityUsingWorkflow     {       private readonly workflowService;            public Order(IWorkflowService service, string workflowKey, string status)       {         this.workflowService = service;         this.WorkflowKey = workflowKey;         this.Status = status;              // Note that the two lambdas are used to retrieve         // and set the state on the entity.         this.Workflow = service.GetStateMachine(workflowKey, () => this.Status, stateValue => this.Status = statValue );       }             public string WorkflowKey { get; set; }       public IStateMachine Workflow { get; private set; }       public string Status { get; private set; }          }      I'm concerned with this design. My basic understanding is that domain entities should not have dependencies injected into them, yet here I am injecting one. I also understand that the entity needs to handle its own state, so I'm hesitant to move the workflow completely out of the entity. Other ideas I've had, like an init method, would just move the injection to method injection. What would be a clean way to design an entity with these requirements? Is it OK to inject a dependency in this situation?


Is it legal / moral to republish oss project of an author that does not respond?

I have found a small oss project (one file) in someone's blog a few months ago. The license is "Attribution-ShareAlike 2.5 Generic". I sent a mail to the author if I can put this in github but got no response back. Meanwhile his blog has been shut down. I am not a lawyer, but this seems legal to republish the code (with appropriate attribution) in github. Am I right? Is this moral? Maybe the guy just wants to disappear for a while...


How can I distribute a unique database already in production?

Let's assume a successful web Spring application running on a MySQL or PostgreSQL database. The traffic is becoming so high and the amount of data is becoming so big that a distributed database solution needs to be implemented to address scalability issue. Let's also assume this application is using Hibernate and the data access layer is cleanly separated with DAOs. Ideally, one should be able to add or remove databases easily. A failback solution is welcome too. What would be the best strategy to scale this database? Is it possible to minimize sharding code (Shard) in the application?


I read Pro ASP .NET MVC 2 Framework - anything else for AJAX in MVC 2?

I read Pro ASP .NET MVC 2 Framework to try and learn the ASP .NET MVC Framework, but I'm really struggling with Ajax in MVC even after going over that chapter again and again. I seem to have a decent grasp on MVC 2 without Ajax. I used the Ajax controls from ASP .NET (non-MVC) and am used to user controls in update panels. I have somewhat complicated objects with nested sets of objects on my website, and trying to update them from the client side and keep their nested array indexes ordered is killing my brain. Having little familiarity with web scripting in general and Javascript / jQuery / JSON in specific isn't helping. Is there anything else I could read that might help me get a better grasp of Ajax in MVC? Is Ajax poorly supported in MVC 2, or am I just struggling because I have huge holes in my understanding of the web due to the WebForms- ish style of the old ASP .NET? Hoping for the latter . . . my own ignorance can be fixed.


Is it possible to modify Lamport's mutual exclusion algorithm to work without a FIFO guarantee?

I'm trying to implement a modified version of the Lamport Mutual Exclusion algorithm. The original algorithm assumes FIFO message ordering between connected systems, but I would like to use ~~UDP~~ a protocol which does not guarantee FIFO. Is it possible to modify this algorithm to work without FIFO? EDIT: Forget UDP. Just assume it is some protocol where the only problem is that FIFO is not guaranteed. That is the only problem I'm concerned with right now.


Should a programmer take writing lessons to enhance code expressiveness?

Given that programmers are authors and write code to express abstract thoughts and concepts, and good code should be read by other programmers without difficulties and misunderstandings, should a programmer take writing lessons to write better code? Abstracting concepts and real world problems/entities is an important part of writing good code, and a good mastery of the language used for coding should allow the programmer to express his thoughts more easily, or in a better way. Besides, when trying to write or rewrite some code to make it better, much time can be spent in deciding the names for functions, variables or data structures. I think this could also help to avoid writing code with more than one meaning, often cause of misunderstanding between different programmers. Code should always express clearly its function unambiguously.


Where does Java get its SOA reputation from?

I see lots of SOA books surrounding Java and have always had the subliminal notion that Java is the "right" language for robust/enterprisey SOA, even though I know what SOA involves and that it is perfectly possible using other languages & frameworks. What _exclusive_ traits Java has that other languages/platforms don't, that makes it so popular for SOAs?


How well do free-to-open-source-projects policies work in practice?

In comparison with an open source license and requesting donations, is a free- for-open-source-projects (or free for non-commercial developers) closed source and otherwise commercial project likely to get more license fees? Or just to alienate potential users? Assume the project has value to programmers - I'm looking for generalizations here, though specific examples comparing existing projects will be very interesting. What I have in mind involves code generating programming utilities. And one issue I can think of, either way, is a near total inability to enforce any license restrictions. After all, I can't go around the internet demanding that everyone show me their source code just in case!


Is it possible to migrate struts/spring based application to GWT?

I am using the combination of spring, spring-security, struts and iBatis in my application. Now I am looking to migrate the struts UI to GWT. The new combination must be spring, spring-security, GWT and iBatis. I applied a layered approach to develop my application. In Controller/UI layer i am using Struts. I want to replace struts and use GWT in Controller/UI layer. Is is possible to use GWT without affecting another layers DAO/BL/SL?


What is an integration test exactly?

My friends and I have been struggling to classify exactly what is an integration test. Now, on my way home, I just realised, that every time I try to give a real world example of an integration test, it turns out to be an acceptance test, ie. something that a business person would say out loud that specs out what the system should be delivering. I checked the Ruby on Rails documentation for their classification of these testing types, and it's now completely thrown me. Can you give me a short academic description of an integration test with a real world example?


How to suggest changes as a recently-hired employee?

I was recently hired in a big company (thousands of people, to give an idea of the size). They said they hired me because of my rigor and because I was, despite my youngness (i'm 25), experienced as a C/C++ programer. Now that I'm in, I can see that the whole system is old and often uses obsolete technologies. There is no naming convention (files, functions, variables, ...), they don't use Version Control, don't use exceptions or polymorphism and it seems like almost everybody lost his passion (some of them are only 30 years old). I'd like to suggest somes changes but i don't want to be "the new guy that wants to change everything just because he doesn't want to fit in". I tried to "fit in", but actually, It takes me one week to do what I would do in one afternoon, just because of the poor tools we're forced to use. A lot my collegues never look at the new "things" and techniques that people use nowadays. It's like they just given up. The situation is really frustrating. Have you ever been in a similar situation and, if so, what advices would you give me ? Is there a subtle way of changing things without becoming the _black sheep_ here ? Or should I just give up my passion and energy as well ? Thank you. ## Updates Just in case (if anyone cares): following your precious advices I was able to suggest changes and am now in charge of the team that must create and deploy Subversion :D Thanks to all of you !


Should I be a good programmer immediately after college?

> **Possible Duplicate:**   >  I've graduated with a Computer Science degree but I don't feel like I'm > even close to being an expert programmer I recently graduated from university, and I have since then joined a development team where I am by far the least experienced developer with maybe with a couple work terms under my belt. Meanwhile, the rest of the team is rocking 5-10 years experience. I was a very good student and a pretty good programmer when it came to bottled assignments and tests. I have worked on some projects with success, but now I'm working with a much bigger code-base, and the learning curve is much higher. I was wondering how many other developers started out their careers in teams and left like they sucked. When does this change? How can I speed up the process? My seniors are helping me but I want to be great and show my value now.


How much inconsistency arises from Javascript's high flexibility?

I'll admit it, I haven't yet mastered the language, but my experience with it tells me that Javascript is a highly flexible language, allowing prototypal inheritance, dynamic typing, functions as first class citizens and so many more cool stuff. I think such features bring some inconsistencies, but that's nothing new, most people would agree with me. I wanted to discuss specific examples that have been annoying me, like "for in" loops:               for(var role in rolesToAdd){                     if(rolesToAdd.hasOwnProperty(role)){                         // for body                     }     }      Why should I need to do this? Doesn't this break the concept of classes and inheritance? I might not want to loop through the whole prototype, but what if I still need some of the attributes/methods from an object's direct parent, for example? Also, I would be most grateful if someone could explain me why the interpreter doesn't allow synonymous global/local variables to share the same scope, when there is certainly a way it could distinguish one from the other. Like in:               var foo = function() {             var wth = bar();             var bar = wth;             // body...     }();          function bar(){         return 'bar mitzvah';     }      You can see that, even though our local bar has been declared after the call to our global bar, bar's value in foo's scope will always reflect the local bar, which will hold 'undefined'. Isn't that a strange behavior? I would love if senior Js programmers enlightened me on this and showed me what is gained from these seemingly strange features and if the disadvantages I mentioned here are valid.


Best Practices for Renaming, Refactoring, and Breaking Changes with Teams

What are some Best Practices for refactoring and renaming in team environments? I bring this up with a few scenarios in mind:   1. If a library that is commonly referenced is refactored to introduce a breaking change to any library or project that references it. E.g. arbitrarily changing the name of a method.   2. If projects are renamed and solutions must be rebuilt with updated references to them.   3. If project structure is changed to be "more organized" by introducing folders and moving existing projects or solutions to new locations. Some additional thoughts/questions:   1. Should changes like this matter or is resulting pain an indication of structure gone awry?    2. Who should take responsibility for fixing errors related to a breaking change? If a developer makes a breaking change should they be responsible for going into affected projects and updating them or should they alert other developers and prompt them to change things?    3. Is this something that can be done on a scheduled basis or is it something that should be done as frequently as possible? If a refactoring is put off for too long it is increasingly difficult to reconcile but at the same time in a day spending 1 hour increments fixing a build because of changes happening elsewhere.   4. Is this a matter of a formal communication process or can it be organic?


Refactoring jQuery spaghetti code to use DDD

Most of my client side code ends up as a long script in one file the mostly looks like this:               <script>     function someFunction1(){/*...*/}     function someFunction2(){/*...*/}     ...     var globalVariable1;     var globalVariable2;     ...     $(function(){          $('selector1').click(function(){         //get relevant data from various DOM elements              //some business logic rules and validation              //open dialog box              //more business logic rules and more validation              //post an ajax request              //update the DOM         });          //many other events          //many jQuery dialogs         });     </script>      It's a maintenance nightmare. Although I use a well designed server-side structure using DDD (application services, domain sevices, value objects,...etc.) I have had little luck structuring my client code to a better separation of concerns. I'm not building a client-side application. I just use jQuery intensively for the client side. How should I approach the code structure to apply DDD client-side wide?


What programming related tasks can you do with a "dead" brain?

Here is my problem: programming (learning about programming, coding, etc) is my hobby. I do it in my freetime.   I have a full time job, which literally drains my brain (no kidding!) by the end of the day so much I can't even add three-digit numbers, but I still want to do some programming-related things. Learning in this state is stupid, finding bugs is impossible. Writing unit test worked sort-of :D   I understand that programming is a very conscious activity, but I need to get my job done every day and I still want to deal with some programming-related stuff, as it's very fun to me. What do you suggest ?   I tought about watching videos, but what topic should I looking for with this state of my mind (which are easy to understand but I can still learn a lot from them) ?   (I can't do it before work, as it is far more important to be fresh there than during my hobby...) Edit: The question need a bit of addition, which I left off intentionally at first, because I tought my question is clear.   I have no problem at all with my brain activity or anything like that, the "brain drain" cause is that I do 9-10 hours _very intense_ mental job a day (much more intense than for example programming or thinking about solving problems), with only less than 5 minutes pause every hour. It is not possible to change it or pause more or think less (huh?!) between those working hours.


Sprint Meetings - What to talk about

In work we have just started using the Scrum methodology, it is working well but I have a question on the daily sprint meetings. We set aside 15 minutes for the meeting (between the three devs and the scrum master if we think he is needed) but I have found that we have normally finished by 5 minutes. This might be because we have said all that needs to be said but I was wondering what people tend to talk about in them, in case we are missing something. For the record we normally update each other on current objective, troublesome previous objectives and plans for the rest of the day (including if we will not be available on that project).


What techniques are there for debugging remote client side errors?

What techniques are there for debugging remote client side errors in a web application, especially when they only affect a small subset of users? In my case we have an app that is working well for hundreds of users, internally and externally, but a handful (12) have a specific problem with a JavaScript that prevents them from using the site. We have screenshots of the error, have confirmed they have no server side errors, confirmed that everything is getting rendered to the browser correctly, have seen the specific error in the IE console, but still have no idea why it isn't working for these specific users. The issue is exhibiting on different versions of IE. We have never been able to replicate the problem here. I'm not looking for a solution to my problem here, but rather what are the steps you would take to solve this kind of problem, and what tools there may be that might help?


Apply filter in Kafka Queue

Is it possible to apply a filter on the Kafka stream of topic? What I want to do is filter out messages while consuming and then run some custom logic on top of it. It is a sort of thing that Storm trident allows us to do ( apply filter on the stream ). What I've found so far is I can create a trident topology and do the filtering but would be of great benefit if I can filter out the stream itself, as it will reduce the amount of traffic at my consumer's end. I know this is crazy but could this be a valid approach? Please correct me if I am wrong.


C++ Interview question

This problem was given to me on previous job interview test. It is over now, but I would like to go through my mistakes and hopefully be more prepared next time!               // Identify as many bugs and assumptions as you can in the following code.     // NOTE that there is/are (at least):     // 1 major algorithmic assumption     // 2 portability issues     // 1 syntax error          // Function to copy 'nBytes' of data from src to dst.     void myMemcpy(char* dst, const char* src, int nBytes)     {          // Try to be fast and copy a word at a time instead of byte by byte              int* wordDst = (int*)dst;         int* wordSrc = (int*)src;         int numWords = nBytes >> 2;         for (int i=0; i < numWords; i++)         {             *wordDst++ = *wordSrc++;         }              int numRemaining = nBytes - (numWords << 2);         dst = (char*)wordDst;         src = (char*)wordSrc;         for (int i=0 ; i <= numRemaining; i++);         {             *dst++ = *src++;         }     }      All I found was a syntax error on line                   for (int i=0 ; i <= numRemaining; i++);      Also the first for loop looks fishy. Can you guys find any other mistakes?


Programming languages with these features

I've got a small project coming up where I can choose any language I want. My team prefers the feeling of safety we get from static typing. In our experience, dynamically typed languages can be more difficult to maintain (we feel they are too "magic"). The usual choice would be Java, but our team is expressing interest in the conciseness and flexibility provided by features of some of the other languages such as Python and Ruby. Based on my team's interests, I need some help evaluating which language to use. Ideally, the language would support these features:   * Statically typed,   * Properties or some form of the Uniform Access Principle,   * First-class functions,   * Anonymous functions (less important). Bonus points for languages that:   * Aren't dependent on Microsoft or any specific operating system.   * Have a non-JVM implementation.   * Have an ORM.   * Have a web development framework. Apart from these criteria, I'd still love to know more reasons why to choose the language(s) in your answer, and any experience you've had with them. Hopefully the answers here will be useful to anyone else that wants to evaluate some alternatives to Java without blindly switching another popular language such as C#. _*Edit: My question was closed due to how poorly I communicated my question before. I hope that I have cleared things up since I got the question re- opened. By the way, I've put my own research into a community wiki answer below, so don't think I haven't done any homework. ;-)_


Where are all the DBAs?

For some reason I got thinking the other day about DBAs and what they do. This thread goes some way to answer this question, but then I looked up the leading jobs site in my area out of curiosity, and it seems like there are more Oracle DBA jobs around than many other technology specialties. Even relatively common-sounding ones, such as "Java Developer" or "Network Administrator". Here's the thing: I've been in this industry for ten years, worked in several jobs (a couple in fairly large corporate shops too), and I've never actually seen a real live DBA. There was usually a self-taught "database guru" around who was the goto guy for database issues (otherwise employed as a developer like the rest of us), but I've never seen anyone in an official DBA role, anywhere, ever. So, where are all the DBAs? I'm guessing that since all the places I've worked so far were relatively application-oriented, I've just never experienced a very hardcore DB-heavy environment. At the same time, at least one of the jobs I've had seemed like a pretty extreme data-centred operation (real time market/trading systems, huge databases), and even here the only "database people" were these "developers who were database gurus on the side". No official DBA roles. Is it really just a case of me never having been in the kind of environment where DBAs are needed? If so, what kind of environment is that? Is this phenomenon perhaps to do with data centres being separate/outsourced operations these days, so most application level programmers just don't see them anymore? **Note:** I am basically trying to understand where the separation between "developers who know databases well" and actual DBAs is. It seems like a lot of dev roles require some pretty hardcore database knowledge these days (and that most development teams - even in quite DB-heavy environments - get by without an official DBA on staff). ie Please don't close or move to dba.SE.


Javascript: Anonymous functions

How do I turn this definition of an anonymous function, An anonymous function is a function that is assigned to a variable. Anonymous functions are also used when you want to perform a short and straight forward task, into an analogy?


Natural Language to Search Criteria - Date Ranges

Consider an application that stores a set of records that contain:   * Description   * Cost   * Purchase Date I'd like to be able to allow users to utilize natural language to search the dataset. For example, the search expression: > blue from last month less than $20 would translate into (Linq as an example only - correctness of the query is not in question):               _db.Widgets.Where(w => w.Description.Contains('blue') && w.PurchaseDate >= DateTime.Now.AddMonths(-1) && w.Cost < 20)      I'm struggling to find a starting point. Any resources to get me in the right direction would be appreciated (I am working in .NET).


Which contract work type provides the most stability while offering flexibility?

I tried my best to frame this question in such a way that it will help others out there who are curious about the same thing as I am. I am currently a full time C++ programmer. I also do a little bit of C#/.NET programming as well. I have over 4 years of experience total. I have looked into the possibility of doing contract programming. I am looking to avoid having to be stuck on one team/project forever. I am single, have no kids, and have enough money saved up to last over a year without an income. I live in one of the biggest cities in the U.S. I know there are different types of contract work, such as W2, independent, contract-to-hire, etc. I'm looking to work on contracts that last 6 months to a year. I would like to avoid having to do most of the marketing/overhead work myself and just want to do the programming work. I thought about getting contract work through different agencies and they would get a cut of the pay for doing the searching/overhead work for me. I just feel so stuck in my current job and want the freedom of working on a variety of projects and have some flexibility in hours and location (whether it's working at home or at another office). I have no desire to move up to management or navigate through office politics every day. What would be the best option for someone in my situation? W2 contracts through an agency? I wouldn't mind getting a little less pay as long as someone would take care of most of the marketing/overhead work involved.


Java Communcation API not available for Windows

I want to write a program in Java using RS-232. But I am unable to find the java.comm Package for the windows. Which library should I use for this purpose? http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive- downloads-misc-419423.html The only package avaiable here are not for Windows. Can you please guide me as I am new to this kind of development. Using rxtx + java I got this code from the internet               import java.util.Enumeration;     import gnu.io.CommPortIdentifier;     public class SimpleWrite      {     public static void main (String args[])     {              Enumeration port_list = CommPortIdentifier.getPortIdentifiers();         System.out.println(port_list);              while (port_list.hasMoreElements())         {             CommPortIdentifier port_id = (CommPortIdentifier)port_list.nextElement();                  if (port_id.getPortType() == CommPortIdentifier.PORT_SERIAL)             {                 System.out.println ("Serial port:" + port_id.getName());             }             else if (port_id.getPortType() == CommPortIdentifier.PORT_PARALLEL)             {                 System.out.println ("Parallel port:" + port_id.getName());             }             else                 System.out.println ("Other port:" + port_id.getName());         }     }      }      But this code gives me error of gnu.io.rxtx.properties has not been detected.


Do frameworks put too much abstraction?

I've been programming for a little under a year and have some experience writing systems applications, web apps, and scripts for businesses/organizations. However, one thing I've never really done is working with a framework like Django, Rails or Zend. Looking over the Django framework, I'm a little frustrated with how much is abstracted away in frameworks. I understand the core goals of DRY and minimal code, but some of this over-reliance on different modules and heavy abstraction of core functions feels like it:   1. Makes programs get dated really fast because of the ever-changing nature of modules/frameworks,   2. Makes code hard to understand because of the plethora of frameworks and modules available and all of their idiosyncrasies,   3. Makes code less logical unless you've read all of the documentation; i.e., I can read through some list comprehensions and conditional logic and figure out what a program is doing, but when you see functions that require passing in arbitrary strings and dictionaries, things get a little hard to understand unless you're already a guru in a given module; and:   4. Makes it difficult and tedious to switch between frameworks. Switching between languages is already a challenge, but it's manageable if you have a strong enough understanding of their core functionality/philosophy. Switching between frameworks seems to be more a matter of rote memorization, which in some ways seems to encourage the very inefficiency these frameworks were designed to eliminate.  Do we really need to put like 50 layers of abstraction on top of something as simple as a MySQL query? Why not use something like PHP's PDO interface, where prepared statements/input testing is handled but the universally understandable SQL query is still a part of the function? Are those abstractions really useful? Isn't feature bloat making them useless, making applications more difficult compared to similar applications written without using a framework?


Static analysis, dynamic analysis and testing

Based on answers I have received here and then confirmed in some authoritative sources (not ISTQB which seems to be too vague), there are 3 activities:   * Static analysis    * Dynamic analysis    * Testing But is there any reason why we cannot combine all of that as "testing"? I mean, even a dynamic analysis review of a program to look for memory leaks is a kind of testing, right?


A little code to allow word substitution depending on user

I'm creating a demo web app in html in order for people to physically see and comment on the app prior to committing to a proper build. Whilst the proper app will be database driven, my demo is just standard html with some JavaScript effects. What I do want to demonstrate is that different user group will see different words. For example, imagine I have an html sentence that says: > This will cost £100 to begin. What I need to some way of identifying that if the user has deemed themselves to be from the US, the sentence says: > This will cost $100 to begin. This requirement is peppered throughout the pages but I'm happy to add each one manually. So I envisage some code along the lines of 'first, remove the [boot US] trunk' where the UK version is 'first remove the boot' but the code is saying that the visitor needs the US version. It then looks up boot (in an Access database perhaps) and sees that the table says for boot for US, display 'trunk'. I'm not a programmer but I can normally cobble together scripts so I'm hoping someone may have a relatively easy solution in JavaScript, CSS or ASP. To recap: I have a number of words or short sentences that need to appear differently and I'm happy to manually insert each one if necessary (but would be even better if the words were automatically changed). And I need a device which allows me to tell the pages to choose the US version, or for example, the New Zealand version.


Streamlining ASP.Net MVC deployment?

I own a VPS with Windows Server 2012 on it. I can install whatever I want on it. In the past when deploying an ASP.Net MVC project, I would right click the project in the solution and `Publish` it. I would then copy over the files to the IIS folder and that would be a `deployment` for me. But this is no longer something I want to do. There has to be an easier way right? How can I streamline the deployment process? I'm 100% in the dark on this subject with .NET. Can I set something up on my server so I can `Web Deploy` to my VPS? Or is there a better alternative? Thank you!


solve TOR edge node problem by using .onion proxy?

I would like to improve the TOR network, where the exit nodes are a vulnerability to concealing traffic. From my understanding, traffic to .onion sites are not decrypted by exit nodes, so therefore - in theory - a .onion site web proxy could be used to further anonymize traffic. Yes/no? perhaps you have insight into the coding and routing behind these concepts to elaborate on why this is a good/not good idea.


ACID compliant Database that isn't NoSQL?

I'm not necessarily asking if a NoSQL database can be ACID compliant, which has been asked here: Is there any NoSQL that is ACID compliant? I'm wondering if we have a database either now or in the future that is wanting or is another option to a traditional RDBMS? I know NoSQL was supposed to be the big thing and RDBMS were supposed to go by the wayside and so forth (I've read I dunno how many articles on it). But that never really solved the issue of data that was very strict and had to be kept consistent (like bank transactions... stuff like that). So when RDBMS was "supposedly" supposed to go to the wayside... what was supposed to replace this Data that had to be strict?


Flat organizations vs hierarchical for software development

My organization was flat two years ago, and people felt that the general manager had disproportionate almost dictatorial powers. Also the general manager didn't have time to coach employees, so some employees were dysfunctional and nothing was done about them. However on the plus side everyone was involved in the decision making, thus motivation was very high. So what do you think about flat vs hierarchical organizational structures in software development?


Understanding clojure keywords

I'm taking my first steps with Clojure. Otherwise, I'm somewhat competent with JavaScript, Python, Java, and a little C. I was reading this artical that describes destructuring vectors and maps. E.g.               => (def point [0 0])     => (let [[x y] point]     =>   (println "the coordinates are:" x y))     the coordinates are: 0 0      but I'm having a difficult time understanding keywords. At first glance, they seem really simple, as they just evaluate to themselves:               => :test     :test      But they seem to be used is so many different ways and I don't understand how to think about them. E.g., you can also do stuff like this:               => (defn full-name [& {first :first last :last}]     =>   (println first last))     => (full-name :first "Tom" :last "Brennan")     Tom Brennan     nil      This doesn't seem intuitive to me. I would have guessed the arguments should have been something more like:               (full-name {:first "Tom" :last "Brennan"})      because it looks like in the function definition that you're saying "no required arguments, but a variable number of arguments comes in the form of a single map". But it seems more like you're saying "no required arguments, but a variable number of arguments comes which should be a list of alternating keywords and values... ?" I'm not really sure how to wrap my brain around this. Also, things like this confuse me too:               => (def population {:humans 5 :zombies 1000})     => (:zombies population)     1000     => (population :zombies)     1000      How do maps and keywords suddenly become functions? If I could get some clarification on the use of keywords in these two examples, that would be really helpful. **Update** I've also seen http://stackoverflow.com/questions/3337888/clojure- named-arguments and while the accepted answer is a great demonstration of how to use keywords with destructuring and named arguments, I'm really looking more for understanding how to think about them--why the language is designed this way and how I can best internalize their use.


Am I overusing trees as a model or are they just very common?

I'm working on a project and I've found that I've modeled the two largest components as trees. My main uses so far are:   1. Generically model physical containers (and sub containers, sub sub containers etc)   2. Model liquid samples (and sub samples, and sample derivatives - and subs of those, etc) I now need to model some events based on the shipment of samples e.g. collected at location X, when arrive at processing centre do Y It now seems natural to model the events as a tree to denote which events follow on from others. I'm starting to wonder if I am just seeing trees everywhere because I want to, or if its a legit approach? **Edit To Answer Some Points Raised** Everyone seems to agree with trees for the containers. For the liquid samples, although there are various types - what I really need to track is parentage so that given any sample, I can quickly find all things that derived from it in some way. I have been told I can assume that samples will not be combined so all sub samples (or derivatives) will have only 1 parent. As to the events, yeah I think I was just going for a tree for ease. It doesn't make much sense to me after reading comments and further thought. Thanks all for the input.


Are symbolic programming and metaprogramming the same thing? I've always read about symbolic programming while using Mathematica, but I've never searched about it's meaning, I've searched about it today and I found that both concepts are similar, are there any differences?


Ever taught yourself drawing/art skills?

I often see programmers advise non-tech people that they should 'just learn to code' if they want to execute their big idea, saying it's not that hard to get the ball rolling. However, while as programmers we can be adept at writing websites including backends and CMSs etc., there's still a great need for the thing **to look nice.** Usually we can leverage clipart and templates etc. and do some image editing to get by. But being able to draw original art yourself would be a big advantage I'm guessing. So my question is has anyone here tried to brush up on their art skills to help with the design aspects of their projects? I know some people have 'always' been good at art, or at least been good at drawing since their highschool days, but I'm curious about anyone who went from being bad at drawing, to regularly completing original art work that went into production on a site or application front-end.


JIT compiler for C, C++, and the likes

Is there any just-in-time compiler out there for compiled languages, such as C and C++? (The first names that come to mind are Clang and LLVM! But I don't think they currently support it.) Explanation: I think the software could benefit from runtime profiling feedback and aggressively optimized recompilation of hotspots at runtime, even for compiled-to-machine languages like C and C++. Profile-guided optimization does a similar job, but with the difference a JIT would be more flexible in different environments. In PGO you run your binary prior to releasing it. After you released it, it would use no environment/input feedbacks collected at runtime. So if the input pattern is changed, it is probe to performance penalty. But JIT works well even in that conditions. However I think it is controversial wether the JIT compiling performance benefit outweights its own overhead.


How is JavaScript insecure, and what are the main methods used to deal with that?

I just read about Caja, which is a "sanitized" version of JavaScript. But I'm wondering - what is the big problem with JavaScript(it seems so widely used )? Just how dangerous is it?


Why I'm not selected in an interview?

I'm working in development for 4 years, and 3.5 in PHP - why I don't seem to be able to be selected in an interview. I want to know what special things the interviewer wants to see in candidates - for senior PHP developer roles. Interviewer asks me 10 questions and I'm able to answer only 5. Does selection depend on these things? It doesn't mean that I can't solve the problem, I can google the question, I can ask on forums. Why don't they understand that a man can't remember all the answers for each and every question? Especially programming ones. Please advise.