title: Unit testing methods with logical dependencies on other classes

text: Suppose I have an interface declaring the following method signature:               SearchResults SearchProducts(string type, string filter, string anotherFilter);      Inside a concrete implementation of this, I instantiate a helper class (call it `QueryBuilder`), built to ease the construction of strongly-typed search queries for the _specific_ search library I'm using. I want to unit test `SearchProducts` (ideally by mocking the query builder), which means I need to decouple the method from `QueryBuilder`. How do I do this appropriately when the two things are _logically coupled_? That is to say:   * It's not appropriate to pass an `IQueryBuilder` into the method as the implementation of `IQueryBuilder` is tightly coupled to the implementer of `ISearchProducts`, i.e. the types of the return values of `QueryBuilder`'s methods are specific to the library being used in the concrete `SearchService`.   * It's not appropriate to pass an instance of `IQueryBuilder` into the `SearchService` constructor (via DI or directly) as the _logical_ scope of the query builder instance is local to the `SearchProducts` method call - it is instantiated in the method, its state is manipulated by adding sub-queries and a complete "query" is extracted _for this`SearchProducts` call_). So, given the above, what's the appropriate way of handling this? It sounds like a case for a factory; however the implementation of this factory would be trivial and it seems a little contrived to define a factory interface and add a constructor parameter just for the sake of testability. Is this indicative of a fundamental flaw in the design of my search interface? How do I decouple these things appropriately such that I can test both the search service and the query builder implementations in isolation?


title: Should software developers be skilled at software design?

text: There is an analysis and design phase of the software development life cycle. Should software developers be skilled enough for carrying out the work performed during this phase, such as drawing workflow diagrams, data flow diagrams, ERDs, UML, and other models? I have seen some cases where developers can code very well given a clear understanding of what is required. However, when they are asked to design a system, they stagger at times.


title: When is a feature considered a "First class citizen" in a programming language/platform?

text: I have seen many times statements like- "Please make this feature a first class citizen in so and so language/platform". For example, it is said about enums in C#/.net. So, when is a feature considered a "First class citizen" in a programming language/platform?


title: The advantage of using __attribute__((aligned( )))

text: I found in more than one SIMD program the instruction `__attribute__((aligned(16)))` . When I looked for an explanation I found > The keyword **attribute** allows you to specify special attributes of > variables or structure fields. Apparently variables have attributes. Are these attributes language-specific? what attributes can a variable have? where are these attributes stored? Regarding the subject of aligned(16), I found this it > causes the compiler to allocate [a variable] on a 16-byte boundary But is it mandatory for SIMD variables ( **m128i for example) to be aligned on a 16 bytes? If yes, I suppose this is the reason why we use __attribute** ((aligned(16))) like so:               int a[16] __attribute__((aligned(16))) = {  1,  2,  3,  4,  5,  6,  7, 8,  9, 10, 11, 12, 13, 14, 15, 16 };          __vector signed int *va = (__vector signed int *) a;


What should be the maximum length of a function? And are there cases which are an exception to this?


title: how to work with web designer?

text: I started my first professional project recently and have hired a web designer to do the layout. My question is how can I sync the work with the designer? Currently our process goes like this:   1. the designer creates a template   2. sends it to me by mail   3. I view, edit & agree   4. the designer codes the html and sends it to me back by mail and so on for each page The problem is, sometimes I get very disappointing html and am forced to have the designer redo alot of work. Is there a way to create a network so that I can monitor his work and provide comments while the work is on-going? I know this is a silly question but I am sure a mechanism for this must exist. :D


title: Should we persist with an employee still writing bad code after many years?

text: I am putting this question to C++ programmers because: a) Only a C++ programmer can judge the technical merits of the examples; b) Only a programmer will have a feel for the temperament of another programmer who writes code like this. HR and the directors are aware there is a problem simply because they see evidence in the field. It's my call whether we give the programmer in question more time. Many of the errors are at a very basic level - my question (to programmers) is whether someone who professes to be a senior C++ developer should be given a benefit of a doubt based on samples of their current code. Non-programmers - even people outside C++ programming - can't make any judgement on this. For background, I've been assigned the task of managing developers for a well- established company. They have a single developer who specialises in all their C++ coding (since forever), but the quality of the work is abysmal. Code reviews and testing have revealed many problems, one of the worst being memory leaks. The developer has _never_ tested his code for leaks, and I discovered that the applications could leak many MBs with only a minute of use. User's were reporting huge slowdowns, and his take was, "it's nothing to do with me - if they quit and restart, it's all good again." I've given him tools to detect and trace the leaks, and sat down with him for many hours to demonstrate how the tools are used, where the problems occur, and what to do to fix them. We're 6 months down the track, and I assigned him to write a new module. I reviewed it before it was integrated into our larger code base, and was dismayed to discover the same bad coding as before. The part that I find incomprehensible is that some of the coding is worse than amateurish. For example, he wanted a class (Foo) that could populate an object of another class (Bar). He decided that Foo would hold a reference to Bar, e.g.:               class Foo {     public:         Foo(Bar& bar) : m_bar(bar) {}     private:         Bar& m_bar;     };      But (for other reasons) he also needed a default constructor for Foo and, rather than question his initial design, he wrote this gem:               Foo::Foo() : m_bar(*(new Bar)) {}      So every time the default constructor is called, a Bar is leaked. To make matters worse, Foo allocates memory from the heap for 2 other objects, but he didn't write a destructor or copy constructor. So every allocation of Foo actually leaks 3 different objects, and you can imagine what happened when a Foo was copied. And - it only gets better - he repeated the same pattern on three other classes, so it isn't a one-off slip. The whole concept is wrong on so many levels. I would feel more understanding if this came from a total novice. But this guy has been doing this for many years and has had very focussed training and advice over the past few months. I realise he has been working without mentoring or peer reviews most of that time, but I'm beginning to feel he can't change. So my question is, would you persist with someone who is writing such obviously bad code?


title: How to save during real-time collaboration

text: I want multiple users to edit same document. Problem I'm facing is when a new user joins, he might see an outdated document. How do I make sure that new users get most recent changes? Some solutions I thought of:   * Save on every change. I don't like this solution because it will slow things down on UI and put load on db.   * When new user joins, trigger save on all other clients. After other clients saved, load document. With this there can be inconsistency still.  Any other suggestions would be helpful. **UPDATE:** After looking into suggested solution, Google Realtime API, I found out that:   1. Users of your app must have Google Drive and give you access to their drive. This could at best present awkward UI flow or prevent users who don't have Google Drive from using realtime feature.    2. All the sharing settings that are done on your side, have to be replicated for Google document.


title: Intellectual Property cost

text: If a piece of bespoke software was developed by a company and the Intellectual Property was retained by the company that wrote it, but now the client of the software company wants to get that source code (and its IP) how much should it cost them? How would you calculate a fair cost for the purchase of that source and IP? **UPDATE** : Just to add, the software in question is of no use to anyone else (for any legitimate purpose) as it ties in directly with the business processes of one company. It is not something that can be subsequently sub- licensed or installed outside the company in question. There are links of to third party services (but these were existing services that the bespoke software had to integrate with in the first place).


title: If I post my source code on a public site, does that automatically make it open source or do I still preserve my rights?

text: This is a weird question but here is why: If I write some JavaScript application, or Perl/Python/PHP cli script, anyone can see the source code. I can even host my code on a public hosting site, like github for example. It will be the same: Anyone can see the code. But will that make my code open source?


title: Session Variables and Proper Implementation

text: Is there any other reason for using session variables besides keeping the values longer than the current request? For instance, is it advisable to use session data when storing information in a file on the file system to prevent one user from writing data to the file of another user? I understand what a session variable is, but I'm not for sure how to properly implement it.


title: What is the limit on REST API resource levels

text: When designing a REST API, how deep should the resources levels go? For example; If I have the following database tables:   * Companies: ID, Name   * Employees: ID, Name, CompanyID   * Tasks: ID, Name, EmployeeID When exposing these through a REST API, it might look something like this (id is optional):   * Companies: GET /api/companies/{id}   * Employees: GET /api/employees/{id}   * Tasks: GET /api/tasks/{id} Lets say I want to retrieve all the employees working at company 1. I could do something like this: GET /api/companies/1/employees, right? Performing a GET on /api/employees would be useless, because you don't want to return all the employees stored in the database. Should the /api/employees resource only be used in this case for retrieving individual data about a specific employee? What if I want to get the tasks associated with an employee? Should the URL be: GET /api/companies/1/employees/123/tasks or GET /api/employees/123/tasks. If you don't want clients to have access to certain resources, without knowing its parent, how do you design your resources? If I'm not being clear enough, or have to many questions, please let me know.


title: Advantages of HTML applications in a Windows intranet

text: I'm preparing a presentation for my team that lists the various technologies we could use today for our business applications. We have been historically building HTML applications (ASP and ASP.net) for the last decade and as part of the introduction I wanted to explain why we moved from Windows applications to HTML. Our environment is:   * Business applications (OLTP mainly)   * Intranet   * Windows clients only   * Complete control on the clients' configuration (OS version/browser version/deployment of plugins...) The only reason I could find is that in the late 90s, deploying a windows client application could end up in a mess (many different versions deployed, dll hell...). Web servers allowed deploying the application once and have all the clients updated simultaneously. The price to pay was a big loss in user friendliness and responsiveness and complexity added to the development job. There are alternatives today (ClickOnce, Silverlight...) but a lot of my colleagues are now totally committed to HTML and the technologies that come along (Javascript/Ajax/Jquery/Css...). I'm totally convinced HTML is great for Internet applications. My question is: at that time (late 90s), were there other reasons to move to HTML in a Windows intranet environment than just fixing deployment issues? (because it was trendy is not a valid answer...) Thanks in advance


title: Closest file match?

text: I am looking for a way to compare a set of files against a given file with each comparison giving me a "closeness" metric. I should then be able to order based upon the metric to find the closest file. I considered using diff, but afaik this only provides a yes or no on whether a particular line matches, which is too large a scale for my purposes as for my purposes a word change in a line of text is closer than a completely different line whereas diff returns no-match for both cases. Would I be able to use a soundex effectively on a 100 or more line file or is there a better algorithm? Also is there a metric which would provide a positive match if the lines which were similar were on drastically different line numbers? Thanks


title: What's the worst programming book you've ever read?

text: What's the worst programming-related or technical book you've ever read? This can be any book which one way or another can be connected to programming, as long as it's not fiction.


title: What are the alternatives to fixed-price or time-and-materials contracts for software development?

text: Proponents of agile methodologies suggest approaches such as multi-stage contracts, target cost contracts, target schedule contracts, shared benefit contracts, and variable scope contracts. Are there other options available, and are there any case studies or informed discussions of these various approaches?


title: Things developers do before the coding phase

text: I'm a new software developer, and in my internship my boss asked me to develop an application that allows him to manage his inventory. Something small but, for me, very enriching. The application is running, he found some bugs and problems but I fixed them. This is not the problem. My problem is that when I was working on the application, I didn't know what I was doing, so everything was in disorder. The project took me 2 months and another developer said that he could do it in a month or less. This surprised me, so I want to know: **How does a professional developer plan a project before starting development?**


title: How can you plan long range resources and budgets when using Agile methodology?

text: Agile does not encourage a lot of up-front design. This is good from a requirements management and software development standpoint, and allows the project to adapt to changing business needs. However, how does one do any long range planning of resources if you don't really know what you're going to build when you start? Oh sure, you have a conceptual model of what you're going to build, but you don't have any measurable detail from which to gague how many resources you will need to complete the project, or how much it will cost. Does anyone have any suggestions on how to go about long range planning in an agile environment?


title: Is a yobibit really a meaningful unit?

text: Wikipedia helpfully explains: > The yobibit is a multiple of the bit, a unit of digital information storage, > prefixed by the standards-based multiplier yobi (symbol Yi), a binary prefix > meaning 2^80. The unit symbol of the yobibit is Yibit or Yib.1[2] 1 yobibit > = 2^80 bits = 1208925819614629174706176 bits = 1024 zebibits[3] The zebi and > yobi prefixes were originally not part of the system of binary prefixes, but > were added by the International Electrotechnical Commission in August > 2005.[4] Now, what in the world actually takes up 1,208,925,819,614,629,174,706,176 bits? The information content of the known universe? I guess this is forward thinking -- maybe astrophyics or nanotech, or even DNA analysis really will require these orders of magnitude. How far off do you think all this is? Are these really meaningful units?


title: Questions for a peer code review

text: I am in the process of creating a short check-list for peer code reviews. So far I have come up with the following...   1. Is there a unit test?   2. Is there a integration test?   3. Do you understand the code you are reviewing?   4. Is it easy to maintain (simple,robust)?   5. Does the code not duplicatie existing functionality ? (Don't reinvent the wheel)   6. Does the code follow (my company's) naming conventions? (variable names,test class names etc)   7. Are all functions, methods and classes documented? (Summary,parameters,comments etc) What do you think of this list? Did I miss something? Is there any standard?


title: Using different DB Connections for different user groups in a web framework

text: Database designers building enterprise systems usually assign different sets of privileges to different users of DBMS. They can be as granular as needed. However, in my experience, web frameworks usually use a single connection to a DBMS, and the privileges are assigned and enforced at the framework level, through some sort of access control scheme. The database connection used by the framework has full privileges on the database, because it may need to create or delete tables, when extensions are installed or removed, for example. Sometimes there are vulnerable extensions of a framework that may allow SQL Injection attacks. These extensions are often developed by third parties, and not by the framework developers. My question is: **What is the efficacy of providing multiple DB connections with varying privileges for different user groups of a web framework - as a security measure?** For example, the connection for a system administrator may allow for creating and deleting tables, but the connection for a public user may only allow for reading certain tables. This would not be a replacement for the Access Control scheme in the framework, but as an added measure against SQL Injection. Is this a good idea, or completely unnecessary? Please explain.


title: Given a set of VLSI chips, how do I determine which are good?

text: I have the following problem: > Given `n` chips [note: these are VLSI chips] out of which majority of chips > are good, we need to find one good chip. The only test that we can apply is > on a pair of chips that answers if both chips are good or both are bad. The > second part is to find a good chip if some tests might produce a wrong > result. Also, the results are systematic meaning that if a pair gives wrong > result, it will always give the wrong result. I have solved the first problem using divide and conquer approach where I reduce the problem set to at least half every time. This can be done by simply performing tests on n/2 distinct pairs every time and keeping those pairs that answer a YES (i.e. both good or bad). I am unable to solve the second part of the problem. A wrong result means that even if two chips are good or bad, the test might answer a NO. Also note that the percentage of wrong tests is very low. How can I go about solving this problem?


title: Designing a plugin-based architecture - what is a protocol service supposed to provide to a plugin?

text: I'm starting a hobby project and I'm in the middle of designing its architecture. I would like to make my program plugin-based (never done anything like that before), to make it extensible. Now I'm trying to grasp how such an architecture is created conceptually. Now, this wikipedia article about Plugins says that the host application is supposed to provide a protocol service (among other things) to establish how data is exchanged with the plugin. I don't really understand this tidbit, what does that mean? What kind of data actually needs to be exchanged? **EDIT:** Just to be clear, I'm not looking for implementation specifics, but for a clear explanation of the mechanism, that the wikipedia article presents. As it stands now, I have no idea what the purpose of a protocol in a plugin- based application is. I figured, the plugin could just fetch relevant data from outside the application on its own and present it to the user, without directly involving the application. What would be the purpose of establishing a protocol for data exchange? It's a desktop application, which will be written mainly in Java, thus object- oriented. The application at its core mainly provides an interface for plugins to register itself in the application and a plugin-manager, which interacts with the plugin.


title: Using C++ but not using the language's specific features, should switch to C?

text: I'm developing a NES emulator as a hobby, in my free time. I use C++ because is the language I use mostly, know mostly and like mostly. But now that I made some advance into the project I realize I'm not using almost any specific features of C++, and could have done it in plain C and getting the same result. I don't use templates, operator overloading, polymorphism, inheritance. So what would you say? should I stay in C++ or rewrite it in C? I won't do this to gain in performance, it could come as a side effect, but the idea is _why should I use C++ if I don't need it?_ The only features of C++ I'm using is classes to encapsulate data and methods, but that can be done as well with structs and functions, I'm using new and delete, but could as well use malloc and free, and I'm using inheritance just for callbacks, which could be achieved with pointers to functions. Remember, it's a hobby project, I have no deadlines, so the overhead time and work that would require a re-write are not a problem, might be fun as well. So, the question is C or C++?


title: Is "poaching" an acceptable way to get open-source volunteers?

text: It is well known that tech companies frequently try to recruit employees from competitors. However, is it common for open-source projects to seek potential volunteers from companies in similar industries? For example, suppose there is an open-source video editing project that really wants to take off. If they were to actively look for volunteers, it would seem that connecting with people from companies like Adobe or Sony would be a good choice. I've been at my current job for almost two years, and I frequently get e-mails from recruiters for similar companies. However, neither I nor anyone else I know have received invitations to participate in an open-source project. This tells me such a practice is uncommon. I know there are legal and ethical issues when it comes to "poaching" employees, but the difference is that the engineer would merely be writing open-source code in their personal time as opposed to leaving their job. So my questions are:   1. Is it common for open-source project coordinators to recruit developers from companies that make similar software?   2. If so, are there any ethical issues in doing so?


title: Does it look bad to take a break between programming jobs?

text: I've been working the same software development job for a few years now but the culture (or lack of proper culture) of the place has finally gotten to me and I have given my notice. To be brief: The bosses created an environment/culture where developers had no incentive to produce quality work. And not only that, any attempts to improve things were actively dismissed by several layers of management. Eventually this became very stressful. I felt like I was fighting someone at every corner just to get things done properly instead of hacking it together like we've always done. Because of this it seems like I haven't learned anything new there for a long time. And now I worry that my skills are becoming less and less relevant on the job market. So, my current plan is to take 3 months off to shake off the stress and to do some major nerding. The idea is to start two or three small projects to learn and apply new technologies/patterns/tools/etc... Essentially, to do everything I didn't have the chance to at my previous job. **The question:** Am I shooting myself in the foot if I take a 3 month break between jobs? Is it always bad to have a break between jobs even if that time is spent improving your skillset? *** UPDATE *** I ended up taking 9 months off. Finding work near home turned out to be harder than I expected, but nobody seemed to even notice the long break in my CV. When I eventually expanded my search to nearby cities as well I quickly found something interesting. The best part is that this new place is happy to let me work from home half of the time :)


title: Javascript idioms this that vs this self

text: I've been writing JavaScript for a bit and have now seen code using the idiom               var that = this;      and               var self = this;      Used to gain access to `this` through closure scope. At this point `var self = this` seems somewhat more common. My question is which of these two idioms is truly the convention? Since they do exactly the same thing, are there advantages/disadvantages to either?


title: Monkey Hunter algorithm - Interview question

text: Question asked in an Interview: You are a hunter in the forest. A monkey is in the trees, but you don't know where and you can't see it. You can shoot at the trees, you have unlimited ammunition. Immediately after you shoot at a tree, if the monkey was in the tree, he falls and you win. If the monkey was not in the tree, he jumps (randomly) to an adjacent tree (he has to). Find an algorithm to get the monkey in the fewest shots possible. **SOLUTION:** The correct answer according to me was in the comments, credit to @rtperson: > You could eliminate this possibility by shooting each tree twice as you > sweep left, giving you a worst case of O(2n). EDIT: ...that is, a worst case > of O(2n-1). You don't need to shoot the last tree twice.


title: What Languages are mostly understood "intuitively" and could benefit from a more formal learning approach?

text: In a presentation, i stumbled upon the Statement "JavaScript is a Language everybody uses, yet nearly noone seems to find it neccessary to learn how it works". And indeed, not many of the programmers i know could explain javascript's prototype concept, or why functions need to be 'bound' to this. CSS seems to be another example of this behaviour: everyone knows how to put a 'class' to an element, and to write a style `.myclass { ... }`, but only a few even know of margin-collapse. My question is: are there more of those languages, technologies, concepts, that are so prevalent that we dont even notice them as something worth learning while we use them?


title: Is there an agile project management technique for developing innovative software systems?

text: I am involved with the development of innovative software. The development is innovative since we don't know how to develop it and what algorithm should we use to implement and nobody else did it before. The process consists of several stages of studying books/papers, suggesting algorithms, writing prototypes and comparing the result with actual data. We hope that after some iteration, we converge to a valid software system. Is there any project management software for these types of projects?


title: Where should date formatting take place in an MVC pattern?

text: Suppose that you want to show a user list, on a web application having to handle custom date formats (depending on current selected interface language). Several locations for applying the date format seem possible. Which one would you use, and why?   * At model, for example doing a `DATE_FORMAT(user.birthdate, '%d/%m/%Y')` for date fields (supposing we have a MySQL DB).   * At controller level, for example (supposing we use PHP):              $users = UserModel::getUsers();     // loops through results before display to format dates.     // in the $users structure, we have to know which fields are dates or not     $users = MagicFunctionFormattingDates($users);          $view = new View('someTemplate');     $view->assign('users', $users);        * At view level, for example (supposing we use a template language such as Smarty):              {foreach key=keyitem item=row from=$users}       <tr>       {foreach key=keyfield item=field from=$row.fields}          {* Here $field should be an Object or associative array             holding its 'type' (is it a date or something else) *}          <td>{MagicFunctionForFormatting field=$field}</td>       {/foreach}       </tr>     {/endforeach}      A similar and related question goes for sumbitting dates (e.g. on a user registration form). Where should the date conversion take place:   * In the controller processing and validating the form, before calling the model?   * In the model?


title: Form screenshot for legal proof of clicking one of the checkboxes?

text: We got a request from one of our customers, and since I've never encountered such a request before, I don't even know where to start looking. Our customer is a network of colleges, and we're building them a site. On that site, among other things, will be a form which potential applicants can fill out in order to get more info about the studies in one of the colleges. After a user fills out this form - including giving their email and/or phone number - the relevant college then contacts them with the relevant info. Now, for legal reasons, the client is asking that this form also have a checkbox that the potential applicant checks to indicate that they agree to get promotional material from these colleges. That's of course no problem. But here comes the weird part of the request: The details of each filled out form have to be be saved in a reliable method. Apparently, saving the form values in a database - a column indicating if the user agreed or didn't agree - isn't enough, because a DB could be changed after the users has sent the form. Our client claims that other college portals create a screenshot of the filled-out form, and save it somewhere in a dedicated folder, in a manner that is easily found, such as giving the file a name that includes the user's name, and the date and time. My question is as follows: have you heard of using screenshots as a method of proving a user has actually filled out a form? Are there other methods that are are considered reliable?


title: Is the license of gifmerge compatible with GPLv3?

text: My doubt arises from this sentence in the gifmerge distribution conditions: "This software may be freely copied, modified and redistributed without fee provided that this copyright notice is preserved intact on all copies and modified copies." Especially the "without fee" part is the one thet puzzle me. Can some expert dispel my doubt? http://www.the-labs.com/GIFMerge/


title: Private apps for iOS and Android

text: Is it possible to develop _private apps_ for iOS (iPhone/iPad) and Android? With "private apps" I mean apps that do _not_ appear on the public app store, but can be downloaded and used only by selected clients.


title: What questions needs to be asked when gathering the initial requirements of a mobile application from a client?

text: Talking generally abount **mobile application development** , I am looking for a list of appropriate questions to ask when visiting the client to get the initial requirements, i.e. what they suppose the application would be at the end. Let's assume that the mobile application idea is something very new for (our) clients and they do not much about what it can do, and how it does them, the only thing they know is they want a mobile application, installed on their phones, and should do what they want. Let's say I am a freelance mobile application developer and I want to get to know what the client thinks and get all the possible aspects that would affect pricing. What I really want is a list of questions, like:   * What is the platforms.   * How long do you expect us to deliver the project.   * etc Of course the list should not/ need not be long. Since the applications that a freelance developer develops is not so complicated, and the poeple who order them do not go through lots of details(since they are not technical enough).


title: Why are most functional programming languages also interpreted languages?

text: Functional/non-functional and interpreted/compiled are two different categorizations, yet it seems that there are a lot of overlaps in the programming languages that fall under those categories. Is this a coincidence?


title: Why chaining matters (Python & SQLite3)?

text: Why does               cursor = connection.cursor()     cursor.execute("...     return cursor.fetchall()      return the expected non-empty result whereas               connection.cursor().execute("...     return connection.cursor().fetchall()      returns an empty list the SQLite3-command being identical in both cases? EDIT 2014-02-19: Added the last "...fetchall()"-line to code samples.


title: If I use LGPL-licensed images in my open-source software project, do I have to use the LGPL for the whole project?

text: ...or, can I license things separately within the project (i.e. images=LGPL, code=GPL). I've been confused about this for a little while now and I can't seem to find a clear answer.


title: UI Field validation in MVP pattern

text: I want to validate the details provided by the user before taking them into the processing. My UIs have Text boxes, Combos mainly and, there are some fields that user must provide a data, in some fields only certain type of data may be accepted like texts, Dates/times, numbers etc. When it comes to date/ time we should check whether the provided data is in the valid range. My question are **Q1. Where to do validation in MVP pattern?** My options are   1. Implement validation as a service available to Presenters. (Through DI for ex.)   2. Do the validation in the UI itself in a event like KeyPress.   3. Presenter itself handles the validation. **Q2. How to do the validation.** My options are i. All controllers like text boxes in the View are encapsulated in properties (Getters / Setters)               public string Age     {         get { return txtAge.Text; }         set { txtAge.Text = value; }     }      ii. UI fires the event Validate(sender, e) iii. Presenter listen and hook it up to the handler which then invokes Validate() method iv. In Validate() method it'll detect the controller raised the event (sender) and read the corresponding property to get the value in the controller. v. Then it will check the type against the type in the model and decide the validity and then alert the user The problem here is that I may have to expose all controllers through string properties as other wise it will give exceptions when the user enters an invalid type.


title: Using AngjularJS with Twitter Bootstrap

text: I want to refactor an OLD legacy application and give it a new feel... so, I want to use Twitter Boostrap for the UI... I've also been playing around a lot with AngularJS... is it common place to use them in conjunction with one another? Is it even the correct question to ask? I've done about an hour's worth of "googling" on the subject and I see a lot of people using the CSS- portion of bootstrap with Angular, however, do I gain anything (or lose anything) by also including the bootstrap .js portion, as well? Thanks.


title: Would md5 hashes allow detection of synced files?

text: We have to develop our own file management system in Java web application. We need to sync files between our main server and client severs and find out whether all the client server has all the latest version of files. Our files are in pdf, doc and xls format they changes every now and then as and when it is required. What we are thinking of using MD5 checksum to find out hashcode of files on Main server and store it in database. Same would be there in Client Servers database. After comparing records on database we would come to know whether client servers are synced or not. Please suggest if there are any better ways to do the same.


title: Places to store basic data

text: I am using PHP. I'm building a fully modular CMS, which is destined for the public. Some people might view this as a framework, but I intend to write a set of extensions for it, extensions that will make it a CMS :P Because it's completely modular I have a problem figuring out how to load extensions. Practically I need to get the list of active extensions, so I can load them inside my base class. I load them by reading some file headers, which contain a "dependency" field. That field decides the order in which I have to instantiate the objects. The problem is that when the CMS starts I have no database interface, because that's an extension too, so I can't store the active extensions list in the database :) You might ask how are extensions activated in the first place. Well - in the administration interface, which is an extension as well (obviously on first install of the CMS there will be some extensions active by default). Could writing that list inside a text file be a solution? The problem is that a lot of hosts are not very nice with scripts when they write files. And since this CMS is public I might have a problem here?


title: Calculate transfer time while accounting for loss of conductivity and speed over circuits

text: So based on my limited understand of how computers work I derived the following question. As you transfer things over circuits the circuits heat up. As they heat up they lose conductivity and ultimately slow down. So how do you calculate the approximate time of transfer for a large amount of files if you take into account for the loss of speed do to drop in conductivity over the wires? To clarify I am talking specifically about local devices, such as HDD to HDD on the same desktop. Also is this even a relative topic? I have noticed slowdown in older drives but I think that was due to the drive itself and not the circuits. This would be useful on older systems though.


title: Shouldn't MVC be MCV?

text: The model is defined first, then the controllers are fired based on the user request, and they will generate the views (the output). So it should be M->C->V, right?


title: .NET BCL Change Analysis - Uses Beyond Sating Curiosity

text: > This is part of a series of questions which focuses on the Abstraction > Project, which aims to abstract the concepts used in language design in the > form of a framework. There is a sister project to Abstraction called > OILexer, which aims to construct a parser from grammar files, without the > use of code injection on matches. > > Some other pages associated to these questions, related to structural > typing, can be viewed here, and ease of use, found here, a question on > writing the compiler compiler can be found here. The meta-topic associated > to an inquiry about the framework and the proper place to post can be found > here. > > One of the steps into this process was building my own ECMA-335 Metadata > parser. Since I tend to build tools to build tools, I recently decided to do > an analytical top-down on the .NET Base Class Libraries. The future goal > will be utilizing it to construct libraries which represent the BCL to aid > in rapid code generation (more on that later if someone cares.) I wanted to get a basic idea of the overall versions of libraries within the .NET BCL, so I analyzed the Framework folder stored locally. Doing this per framework version should reflect the end-user's system: right now I'm targeting myself. The first step in this goal is to construct a class which conceptualizes a multi-versioned library and pulls in each iteration as needed. The next step is pulling in all the types from each version and comparing the individual lists of types (oddly more work than it should be.) The result is a fairly straight forward view of the BCL which breaks down the version a library was introduced, and displays which version new types were introduced, grouped by namespace. This **should** be an exhaustive list which excludes types which were introduced with the library itself. You can assume that if it isn't listed, it was there from the library's inception. The view is very simple: `+Type` means it was added, `-Type` means it was removed `Type->Assembly` means it was relocated at that version. The objective side of this is: if it's accurate, it gives you a basic breakdown of when a type was introduced, useful for determining the lowest version of .NET needed for a given piece of functionality. The next step is member analysis which will make the first step look easy (mostly due to method signature comparison, since each parameter type will have to be reversioned and looked up.) I'm curious if this analysis could later be used for an automated tool which could determine the lowest common framework version for an assembly as a whole (software being written by the compiler framework I'm writing, that is)? Insight welcome. > PS: To those wondering why I don't use Reflection, attempt using > Type.GetType(string) on any of these: >   >   >     Microsoft.Win32.Registry, mscorlib, Version=1.0.3300.0, Culture=neutral, > PublicKeyToken=b77a5c561934e089 >     Microsoft.Win32.Registry, mscorlib, Version=1.0.5000.0, Culture=neutral, > PublicKeyToken=b77a5c561934e089 >     Microsoft.Win32.Registry, mscorlib, Version=2.0.0.0, Culture=neutral, > PublicKeyToken=b77a5c561934e089 >   > > It won't fail, but you also won't get what you would expect, even trying to > load the 2.0 mscorlib by filename yields the 4.0 assembly. **Edit** : I should add this analysis purely focuses on the publicly exposed elements. The rationale for this is you shouldn't ever focus on the dependencies of the internal structure of the BCL since it can change without warning. If you're writing a code generator and the expressions you synthesize rely on these types, your system is likely to be fragile as glass if something changes in the framework, like a patch that updates the 2.0 version's internal structure. Due to how .NET binds its members in Common Intermediate Language, this is a very real likelihood.


title: Is spying on tested class bad practice?

text: I am working on a project where class internal calls are usual but the results are many times simple values. Example ( **not real code** ):               public boolean findError(Set<Thing1> set1, Set<Thing2> set2) {       if (!checkFirstCondition(set1, set2)) {         return false;       }       if (!checkSecondCondition(set1, set2)) {         return false;       }       return true;     }      Writing unit tests for this type of code is really hard as I just want to test the condition system and not the implementation of the actual conditions. (I do that in separate tests.) In fact it would be better if I passed functions that implement the conditions and in tests I simply provide some mock. The issue with this approach is the noisiness: _we use generics a lot_. A working solution; however, is to make the tested object a _spy_ and mock out the calls to the internal functions.               systemUnderTest = Mockito.spy(systemUnderTest);     doReturn(true).when(systemUnderTest).checkFirstCondition(....);      The concern here is that the SUT's implementation is effectively changed and it may be problematic to keep the tests in sync with the implementation. Is this true? Is there best practice to avoid this havoc of internal method calls? Note that we are talking about parts of an algorithm, so breaking it out to several classes may not be a desired decision.


title: Challenges for the experienced coder to learn functional programming?

text: What are the challenges that an experienced programmer with the usual C++/UNIX background would face when trying to learn functional programming? The main motive for learning is to gain a fresh perspective, perhaps that'd help write better code. This is debatable though. Should Haskell be the introductory language or Prolog or Lisp or F#?


title: Consequences of "naïve" vs "naive"?

text: While using IE autocorrect "naive" got transformed to "naïve"! My regional settings are Au English, from a Unicode search point of view the two are nothing alike. I am not even sure whether there are other characters that are being replaced, but from a programmers point of view what are the consequences and remedies in such cases? In SQL is there a way to return results containing both "naïve" and "naive"? (without hardcoding or explicit programming of course). Are there other instances of automatic transliteration that one should be aware of? Or is there a method to handle such sameness of characters in other languages? e.g. umlats in German and lack/inclusion of vowels in Arabic script based words. Thanks for any observations on this matter


title: Java desktop application using MVC + Hibernate

text: I'm developing a Java desktop application. I'm planning to use MVC architecture described at Oracle site: Java SE Application Design With MVC. I need to store data in database so I decide to use Hibernate as it is very simple but there is any tutorial that use Swing+MVC+Hibernate. It is possible to use them together?


title: Checking a record is due based on the 'occuring' field

text: I have records that have dates against them and an occurring field that contains `none`,`yearly` and `monthly`               id    status    note   date        last_updated   occurring     1     open      ---    01/01/2011  01/02/2010     yearly     2     open      ---    05/05/2011  03/05/2011     monthly     3     open      ---    06/06/2011  05/06/2011     none      Now I need to be able to check if a record is due (the date set has passed) which works perfect if `occurring` is set to none but I'm unsure of how to approach it when it's set to yearly or monthly (IE: This day in the year/month has passed) So with the above records, if I had a method on the record called `due?` providing the status is 'open' it needs to return `true` every year when it's passed that date if it's not been updated within the year yet. I apologise if this is confusing but it's melting my brain just trying to think of it, let alone put it into words.


title: Where to store global enterprise properties?

text: I'm faced with a crowd of java applications, which need different global enterprise wide properties for operation, for example: hostname of the central RDBMS, hostname and location of the central self-service portal, host location of central LDAP, host location of central mail server etc. Formally we build each application with a properties file, where all this properties are definied. But that's a very bad solution, because if the hostname of the mail server changes, we need to change the properties files for each application and deploy all applications again. Our idea is to centralize this properties, so that each application can ask for each property at runtime, for example:   1. Idea: Put the properties file to an easy accessible file share. So if we need to change a property, each application uses the new properties.   2. Idea: Put the properties to database. Main disadvantage: we need a dependency to database client libraries for each application.   3. Idea: Put all applications into one big application server, that provides system properties for each application. Main disadvantage: needs deployment of each application to one application server. But that isn't a realistic scenario.   4. Idea: Webservice that provides global enterprise wide properties. Main disadvantage: not very secure, because some properties are passwords or user credentials. What other alternatives are recommended? What is state of the art?


title: Coping with test code becoming too complex

text: Our test automation team writes tons of automation tests for our WEB application, but it seems to me that their code is becoming way too complex and warrants that someone will test it as well. Is there a best practice for writing these automation tests? I'll appreciate any answer with concrete inputs from someone who experienced this problem. If it matters - we are using jSystem for automating our WEB application tests - if there are frameworks which simplify life - I'd like to hear about them.


title: In the days of modern computing, in 'typical business apps' - why does performance matter?

text: This may seem like an odd question to some of you. I'm a hobbyist Java programmer. I have developed several games, an AI program that creates music, another program for painting, and similar stuff. This is to tell you that I have an experience in programming, but not in professional development of business applications. I see a lot of talk on this site about performance. People often debate what would be the most efficient algorithm in C# to perform a task, or why Python is slow and Java is faster, etc. What I'm trying to understand is: **why does this matter?** There are specific areas of computing where I see why performance matters: games, where tens of thousands of computations are happening every second in a constant-update loop, or low level systems which other programs rely on, such as OSs and VMs, etc. But for the normal, typical high-level business app, why does performance matter? I can understand why it used to matter, decades ago. Computers were _much_ slower and had much less memory, so you had to think carefully about these things. But today, we have so much memory to spare and computers are so fast: does it **actually** matter if a particular Java algorithm is O(n^2)? Will it actually make a difference for the end users of this typical business app? When you press a GUI button in a typical business app, and behind the scenes it invokes an O(n^2) algorithm, in these days of modern computing - **do you actually feel the inefficiency?** My question is split in two:   1. In practice, today does performance matter in a typical normal business program?   2. If it does, **please give me real-world examples of places in such an application, where performance and optimizations are important.**


title: Developing an iOS app for a single device - licensing issue

text: I'm developing an iOS app for a museum as a freelancer. It's a very simple video player, to be installed on a single iPad that will be part of a permanent exhibition, basically acting as a kiosk. It turns out the iPad is the ideal device for that if you're looking for a small and affordable touchscreen. The problem is: as far as I can tell, none of the Apple Developer Program options available will allow me to distribute an app like that. The relevant options are (from the link above): > **iOS Developer Program ($99/year)** Select this program if you would like > to distribute apps on the App Store as an individual, sole proprietor, > company, organization, government entity or educational institution. > > **iOS Developer Enterprise Program ($299/year)** Select this program if you > would like to develop proprietary apps for internal distribution within your > company, organization, government entity or educational institution. The regular program requires distribution through the App Store. The Enterprise version is for internal distribution within _my own organization_. Neither is the case here! It seems like I'm doomed to violate Apple's terms of service (and I can think of at least two ways of doing that: jailbreaking, or changing the iPad's date so it won't know the provisioning profile expired). Is that really so, or did I get the descriptions wrong? Has anyone here been in a similar situation?


title: How exactly to use the MVC design pattern

text: I have read the documentation on the apple's developer website which refer following guidelines >   * A view class shouldn't depend on a model class (although this may be > unavoidable with some custom views). >   * A view class shouldn't have to depend on a mediating controller class. >   * A model class shouldn't depend on anything other than other model > classes. >   * A mediating controller class shouldn’t depend on a model class > (although, like views, this may be necessary if it's a custom controller > class). >   * A mediating controller class shouldn't depend on view classes or on > coordinating controller classes. >   * A coordinating controller class depends on classes of all MVC role > types. > Consider this scenario: I have a view controller class called `EmployeeViewController`. I have some minor components of which are some are programmatically created and some are created through `xib`. What exactly I am doing is creating all the subviews inside the `EmployeeViewController` class and adding them to the `EmployeeViewController`'s view, e.g. `[self.view addSubView:…]` Is it a better option for me to create a seperate `UIView` Subclass which consists of all the components and initialize it once and add it in the `EmployeeViewController`? What exactly is the correct way to implement MVC? Am I supposed to create separate components for view and controller or should I stack subviews inside the `EmployeeViewController`?


title: One large project or a few small ones?

text: Personally I'd prefer to work on one project at a time, maintaining absolute focus on that. I find I'm at my most productive in this situation, however it's not always the way things happen in the real world. Do you prefer working on one large project, and being totally focused on that, or be working on say 3-4 small projects at once which may even be developed using different languages?


title: Unit testing code paths

text: When unit testing using expectations, you define a set of method calls and corresponding results for those calls. These define the path through the method that you want to test. I have read that unit tests should not duplicate the code. But when you define these expectations, isn't that duplicating the code, or at least the process? How do you know when you're duplicating functionality under test?


title: Should the number of developers be considered when estimating a task?

text: I am pretty inexperienced with working in agile projects but I have tried it a few times and I always run into this problem when estimating a task. Do we bring into the estimate the number of developers that will work on the task? Let me explain: Task A is estimated to one time unit and developer 1 will work on it. Task B is also estimated to one time unit and developer 2 and 3 will work on it together. I.e. if developer 1 begins to work on task A at the same time developer 2 and 3 begins to work on task B they will all finish at the same time according to the estimate. Should the estimate for task B be twice of that for task A or the same? The problem as I see it is that when a task is received and estimated, it is not always possible to know how many people will work on it. And if you assumed that two developers would work on the task for one time unit but it turns out that only one developer will actually do it, this will not automatically mean that that developer will work on it for two time units. Is there any standard practice for this?


title: Branching an application setup/installer across versions?

text: I am wondering whether I should branch our installer script/project-file (we use InnoSetup) with each application release or whether I should keep one in installer script that generates the setup for all versions and branches. ## Background We use branches ("maintenance versions") heavily as our features are very customer driven and we often first implement a bugfix in a specific customer version to keep things stable. (Yes. Not optimal. But it's also what the customers like. As little code-changes as possible to take no risk with their expensive hardware lying idle because of regressions.) So our branches/versions would look like this               v150.6 - "150" branch installed with customer X      v151.7 - "151" branch installed with customer Y, Z, A and B     ...     v156.3 - "156" branch installed with customer C and D     vCurrent - Development of new features - will produce a v157 eventually      I have now checked in our setup script into version control and it already has seen quite a few bugfixes and tweaks. At the moment, when a new v151.n+1 maintenance version is built, the automated build scripts take the setup script checked into v151 branch and create a setup with this. So obviously, a v151.8 version would have a bit an outdated installer, although "95%" of all fixes to the installer would be applicable to all old releases. _I am therefore considering adjusting our automated build scripts to always use the setup script from the vCurrent branch: - also for the setups of newly created maintenance versions of old branches._ What is your take on this. **Should a setup/installer script be** "tightly bound" to a sourcecode version, or should the lifecycle of setup logic be more independent from the actual code-version/binaries being installed, so that fixes to the setup logic can be used across a range of different (maintenance) versions?


title: Company namespace in web applications

text: Most (good) namespace conventions require a company name scoped namespace. **eg** `CompanyName.ComponentName.x.y.z` How well does this translate over to web applications? In many websites, the company is referred to by the website name (eg, Facebook, MySpace). Does this convolute namespaces, making them appear as if they can only apply to a single project? **For example** , let's pretend a company creates _WebsiteA_ (.com), and is henceforth referred to as ' _WebsiteA_ '. _WebsiteA_ creates a reusable authentication component for their project. They namespace it as such: `WebsiteA.Auth.x.y.z` A year later, _WebsiteA_ creates a new website, _WebsiteB_ , and decide to use their previously created `WebsiteA.Auth` component. Does this obscure the namespace? Should the company have used an alias separate from their website name as their CompanyName in their namespacing? Afterall, `WebsiteA.Auth` isn't coupled directly to _WebsiteA_.com, and `WebsiteA` is now more of a project of the company, rather than the entire company.


title: Should I build my own CMS or rely on a pre-built one?

text: > **Related** : As a beginning programmer, should I favor building my own > libraries over using 3rd-party libraries? As an intermediate to advanced level PHP web-developer and a young one at that (15yrs.), should I build an entirely new CMS for my website or rely on pre- made software such as WordPress or Drupal? I don't exactly feel that WordPress is powerful/scalable enough to be able to handle what I'm trying to do and after tinkering with Drupal quite a bit over the last few days it just doesn't seem up to par for my liking and also isn't well documented so I'm having a bit of trouble getting it to do certain simple tasks. I would _love_ to use something such as ExpressionEngine, but I don't have the money to dish out for a commercial license which is currently at around $300, so that's a no-go. I originally started coding my site as a temporary system so my users could purchase upgrades and other things such as in-game currency until I could get a new website up, but after I started on it I quickly realized that I needed to make it scalable, so from then on I coded with the thought of making it a full-functioning website in mind. It only took a couple of days but all of the basics are there (register, login, account modifications, etc.) and I believe it would be a great start for a private CMS. The last thing I want to add is if I were to build my own CMS, should I make use of a PHP framework such as CodeIgniter, which I have quite a bit of experience with? Maybe others developers could clue me in as to what I may be getting myself into.


title: To check-in small chunks and frequently, or to check-in large chunks but infrequently

text: Which approach is better when working with a source control software like TFS or VSS? I have experienced different approaches and I can't tell which one is better. Should we let developers decide upon it? Or should a team has a unique strategy for check-in check-out operations?


title: Should SCRUM be used for a project with only one person working on it?

text: At our company we have a team working on 3 different projects at the same time, where typically only one or two people are involved in each project. Project work often involves mastering new technologies and or solving bugs, both leading to tasks which are very hard to estimate. In this situation, the management still insists on using SCRUM and does not allow allocating a safety buffer at the end of the sprint for unexpected situations. The stand-up meeting happens for the whole team, although pretty much everyone works on unrelated software components or different software projects all together.   * I was wondering if someone have seen SCRUM working well for a project with a single developer and fuzzy tasks, and how you made the process work well?   * How to estimate tasks which involved research/mastering new technologies (this involves learning new programming languages, platforms, and development tools)?   * Has anyone succeeded in convincing management not to use SCRUM for particular projects, and if yes, which arguments were most successful? Thanks!


title: In startups does one get an adequate feedback on his performance? Or does a "bang" come unexpected?

text: I started working for a start-up company. Generally the pace is very fast and have a lot of expectations. This is different for me since I used to work for a big company with a lot of structure and the pace was not that high.   From discussions with other collegues (not within the new company of course), my conclusion is that it is easy to lose your job in a start-up. I guess this makes some sense since the company "struggles" to survive.   What I would like to know is if in general, if indeed this is the case and it is easy to get laid off, is one usually warned if he is up to the expectations or not in order for him to improve? Or there is no such warnings?   Well if they are not satisfied do they tell you? Would it be possible to not be satisfied and hide it? And then just let you go?   Is constant/adequate feedback of employee's performance part of a start up's mentality?   I am looking for advice from colleagues with more experience on this.   Any input/advice is highly appreciated.


title: How should I document a Python script?

text: I have a couple of Python modules that are meant to be run as scripts. How should I write the docstrings at the module and function level to make it clear how to run and use the module?


title: Is .NET experience information overload?

text: It used to be that, if you wanted to develop an N-Tier app in .NET you built your UI with Winforms or WebForms, your BLL with standard C#/VB.NET/{.NET Language}, your DAL with ADO.NET and maybe throw in some remoting. Now you've got, WPF, ASP.NET, ASP.NET MVC, Silverlight, WCF, WCF Data Services, WCF RIA Services, WF, EF, P&P App Blocks and more. That's just _some_ of your options if you want to build an N-Tier Application using .NET, and - maybe I'm just not that smart but - few of these are easy to learn well. _And_ these are only products from Microsoft. Nevermind the other myriad tools & technologies (other ORMs, UI frameworks like PRISM, AOP frameworks etc. etc. ad nauseum). Is it freedom of choice, is it information overload, or is it normal and I'm just slow/dumb?


title: Directly copying third-party API

text: I'm currently planning on implementing API for HgLab and the obvious role model for me here is GitHub. My API obviously won't be an _exact_ copy due to inherent differences between Mercurial and Git and due to different tasks GitHub and HgLab solve, but similarity will be quite clear. How ethical of me will it be to copy their API to a significant extent? Is the API design copyrightable?


title: PHP - Data Access Layer

text: I am currently reviewing a code base and noticed that a majority of the calls (along with DB connections) are just buried inside the PHP scripts. I would have assumed that like other languages they would have developed some sort of data access layer (Like I would do in .Net or Java) for all of the communication to the DB (or implemented MVC, etc). Is this still a common pattern in PHP or is there alternative methodologies/patterns for this technology? I am just trying to understand why the subs would have developed it this way. Any insight/info on how experienced developers design an approach data access in PHP would be very much appreciated.


title: how to get more and better contribute in github?

text: I have use github for a while, but my project is only one developer -- myself. I want to get some contribute from others, and some of my friends said they can give me some patch, but we all don't know how to use github as a tool for us. And I know that github will also help project get more contribute from the open source community. So, my question is   1. how to get contribute in github?   2. how to get more and better contribute from opensource community?


title: Help me classify this type of software architecture

text: I read some books about software architecture as we are using it in our project but I can't classify the architecture properly. It's some kind of Enterprise Architecture, but what exactly... SOA, ESB (Enterprise Service Bus), Message Bus, Event Driven SOA, there are so many terms in Enterprise software.... The system is based on custom XML messages exchanges between services. (it's not SOAP, nor any other XML based standard, just plain XML). These messages represent notifications (state changes) that are applied to the Domain model, (it's not like CRUD when you serialize the whole domain object, and pass it to service for persistence). The system is centralized, and system participants use different programming languages and frameworks (c++, c#, java). Also, messages are not processed at the moment they are received as they are stored first and the treatment begins on demand. **It's called SOA+EDA -:)**


title: Why it is important to include definition of success/failure in specification?

text: I've read Steve McConnell's "Code Complete" and one of items in checklist for requirements is: "Is the definition of success included? Of failure?". Why is this important? Can you write any examples of those definitions? Can anybody provide examples of good requirements specification?


title: Which to choose, procedural programming or object - oriented programming?

text: I want to build a website that runs e-commerce (C2C), thus I want to ask which programming approach is more appropriate and advanced in terms of website's functionality?


title: Domain model for education

text: Are there any domain models already created for education industry? For example we have Prima IBCS for insurance. I was looking for something along similar lines.


title: What is your most unusual javascript concept you've ever seen?

text: I've learned javascript at school but since I'm working with it and study about it every day, I've found very particular aspect of javascript that I didn't know about. Which at first, was very hard to understand for me and finally, I found it very usefull and easy to implement. And in the final, it gives to my code some kind of "beauty". An example I've once seen:               function getter( input )     {         result = {             foo1 : 'bar1',             foo2 : 'bar2',             foo3 : 'bar3'         }[input] || input || "default";              return result;     }      **Do you guys have other examples of particular use you make of Javascript ?** Thank you **PS:** I use the term _particular use_ because it might be unusual for any Javascript beginner. I believe this question is most likely to belong to the community wiki.


title: JSON - Ruby objects key naming

text: Ruby object has method/property:               def tentakles_count       8     end      JavaScript object has key/property:               { justEnough: true }      Now, when JavaScript gets serialised ruby object via XHR or WebSocket, developer has to use alien naming convention to access `tentacles_count`. The same goes for Ruby, when it gets json object POSTed, developer has to use alien naming convention to access `justEnough`. What would you do to deal with this little imperfection without going too crazy?


title: DDD - Domain Driven Design, which development order should be applied?

text: 1 - Design my entities, ie (in python):               class Account:         def __init__(name, author):             self.name = name             self.email = email      2 - Design my repositories: (as interface)               class AccountRepository:         def add(self, account):             """ @type account Account """             pass              def find_by_name(self, name):             pass              def find_by_email(self, email):             pass              # remove, and others...      Now, I can go two ways: **A:** Design and implement my domain services:               class SignUpService:         def __init__(self, account_repository):             """ @type account_repository AccountRepository """             self._account_repository = account_repository              def create_account(self, username, email):             account = Account(username, email)             self._account_repository.add(account)              # other methods that uses the account_repository      **B:** Implement my Repositories Strategies:               class MongodbAccountRepository(AccountRepository):         def __init__(self, mongodb_database):             self._mongodb_database = mongodb_database              def add(self, account):             account_data = account.__dict__             self._mongodb_database.accounts.insert(account_data)              # and the other methods      Which is the correct order? and why? 1, 2, A, B or 1, 2, B, A? Thank you so much!


title: Assert Message in Unit Tests

text: I've just begun reading "The Art Of Unit Testing" by Roy Osherove, and while I'm mostly finding the material very helpful, he makes a statement about not using messages in your Assert statements. > "Please never, _ever_ , use this parameter. Just make sure your test name > explains what's supposed to happen." My question is, in you experience do you find this advice to be good or bad? If you use assert messages in your unit tests, what information do you use it to capture beyond what a well named unit test could give you in the first place?


title: Are closures considered impure functional style?

text: I have a few related questions on closures: Are closures considered impure in functional programming? It seems one can generally avoid closures by passing values directly to a function. Therefore should closures be avoided where possible? If they are impure, and I am correct in stating that they can be avoided, why do so many functional programming languages support closures? **Edit:** I'm adding a little more context to help explain why I am confused about this. I read on wikipedia that one of the criteria for a pure function is that "The function always evaluates the same result value given the same **argument value(s)**." http://en.wikipedia.org/wiki/Pure_function Suppose               f: x -> x + y      `f(3)` will not always give the same result. `f(3)` depends on the value of `y` which is not an argument of `f`. Thus `f` is not a pure function. Since all closures rely on values which are not arguments, how is it possible for any closure to be pure? Yes, in theory the closed value could be constant but there is no way of knowing that just by looking that the source code of the function itself. Where this leads me to is that the same function may be pure in one situation but impure in another. One cannot _always_ determine if a function is pure or not by studying its source code. Rather, one may have to consider it in context of its environment at the point when it is being called before such distinction can be made. Am I thinking about this correctly?


title: Versioning and client upgrade strategy for web applications

text: I'm writing a web app and am wondering about future upgrades and how upgrading the webapp will affect the user experience. In particular, I was wondering how a company like Google approaches this problem. For example, I have seen several examples where a particular google app will ask the user if they want to upgrade to 'the new google docs', or similar. This is the experience I would like to provide, but I'm not sure how to go about it. If it matter, I'm writing an app that uses backbone.js and has a heavy JS client side component. I have seen several discussions talking about versioning the REST component or the WebServices component, but none that discuss the actual client-side code or backend components (of course, the backend may not matter much if it is all behind a versioned webservice) I'm interested in how they achieve this, from an application standpoint and from a (presumably) backend DB standpoint. So it seems like there are several issues.   * Where in the web root do the versioned applications live?   * How do you serve multiple versions to different users?   * How do you version the backend datastore?   * Since I'm using backbone, I am particularly interested in to design the router for this type of app. If the various versions live in a subdir, how do I create a proper router? There are probably some other considerations as well. Any advice would be welcome.


title: how to compare two large sets of data using PL/SQL?

text: I have two different tables in two separate databases with around 1.5 million records each. (BTW: im working on oracle databases) The objective is to check if every record present in table A is also present in table B. Since the tables exist in different databases, I think I cannot calculate the "difference" between the two of them, so what im currently doing is selecting the column I need from each database and storing all the rows on separate text files. Then, I load the content of one of the files on a dictionary (using python) and then iterate the other file checking if every line is present on the dictionary. I would like to make this more simple, perhaps directly on a stored procedure in the database. My main concerns are:   1. I don't know if PL/SQL associative arrays are as efficient as the dictionary (im assuming python dictionaries have constant lookup time)   2. The fact that tables exist on different databases makes me think that it would be impossible to "reach" the contents of table B if the stored procedure is on the database of table A, or viceversa. Thanks in advance for any suggestion!


title: ORM and component-based architecture

text: I have joined an ongoing project, where the team calls their architecture "component-based". The lowest level is one big database. The data access (via ORM) and business layers are **combined** in various components. E.g., there's a component for handling bank accounts, one for generating invoices, etc. So every component contains the data access to only a part of the schema. My issue is the coupling of data access and business logic in such a structure, because while such a partition makes sense for business logic, it complicates data access. From my point of view the separation of the data access layer into various components seems counterproductive, because it denies us the relational mapping capabilities of the ORM. E.g., when I want to query all invoices for one customer I have to identify the customer with the "customers" component and then make another call to the "invoices" component to get the invoices for this customer. The entity Customer can't have an Orders property, because Orders are mapped in a different component. Does anybody have some advice? Have I overlooked something?


title: Suggestions wanted on dealing with hyper territorial team

text: I have just started a new job and all is not well in neverland. I had high hopes for this company, but when I arrived, I walked into a team that I am having a hard time working with... The two existing developers on this project are having a hard time accepting any suggestions or changes to the code that they spent the last few months writing. It seems like a political minefield and so far their way of dealing with a new team member has been to avoid explaining as much as possible. example: this is a rewrite of an existing system and apparently I don't need to know anything about the old system because they have already reviewed it and know what needs to be done. I don't want to make this a long rant, but there are other issues including micro-management, assigning only trivial bug fixes, and an unwillingness to consider any suggestion, idea, or minor code change that is a departure from how it is currently written. Example: I had a bug fix to make sure a search screen truncated names longer than 25 characters. One of the existing developers made the comment that I need to talk to them before I start so he can show me how the existing string truncate is done, LOL. If I check in code without consulting them first then "the team" decides that it needs to be reworked. HOW do I deal with this? Has anyone out there ever overcome similar issues? Is this just a lost cause??? P.S. I'm not a junior level or incompetent programmer. I'm no rock star, but I've got as much experience and knowledge as the rest of my team, so I don't think that is the underlying issue.


title: Stuck due to "knowing too much"

text: Note more discussion at http://news.ycombinator.com/item?id=4037794 I have a relatively simple development task, but every time I try to attack it, I end up spiraling in deep thoughts - how could it extending the future, what are the 2nd generation clients going to need, how does it affect "non functional" aspects (e.g. Performance, authorization...), how would it best be architectured to allow change... I remember myself a while ago, younger and, perhaps, more eager. The "me" I was then wouldn't have given a thought about all that - he would've gone ahead and wrote something, then rewrote it, then rewrote it again (and again...). The "me" today is more hesitant, more careful. I find it much easier today to sit and plan and instruct other people on how to do things than to actually go ahead and do them myself - not because I don't like to code - the opposite, I love to! - but because every time I sit at the keyboard, I end up in that same annoying place. Is this wrong? Is this a natural evolution, or did I drive myself into a rut? Fair disclosure - in the past I was a developer, today my job title is a "system architect". Good luck figuring what it means - but that's the title. * * * Wow. I honestly didn't expect this question to generate that many responses. I'll try to sum it up. Reasons:   1. Analysis paralysis / Over engineering / gold plating / (any other "too much thinking up-front can hurt you").   2. Too much experience for the given task.   3. Not focusing on what's important.   4. Not enough experience (and realizing that). Solutions (not matched to reasons):   1. Testing first.   2. Start coding (+ for fun)   3. One to throw away (+ one API to throw away).   4. Set time constraints.   5. Strip away the fluff, stay with the stuff.   6. Make flexible code (kinda opposite to "one to throw away", no?). Thanks to everyone - I think the major benefit here was to realize that I'm not alone in this experience. I have, actually, already started coding and some of the too-big things have fallen off, naturally. Since this question is closed, I'll accept the answer with most votes as of today. When/if it changes - I'll try to follow.


title: New application development - Use existing database or create a new one?

text: A Client has a huge Windows Application running on a Database. This client wants you to develop an "Express" version of this application, including only, let's say, 20% of its features. This Express version must be a Web Application, opened on the WWW. You have 2 choices:   * Use the same Database to develop the web application   * Create a new database to the web application, including only the necessary tables and objects and use some synchronization mechanism to keep the databases up to date. The client prefers the 2nd option, because: Security: If they have a separated Database for the web app, they will not "expose" the huge Windows App Database on the internet. Performance: The windows application has some huge process that they run at night and "lock" the database for a couple of minutes. So, creating a separated DB would ensure better performance to the web application. I prefer the 1st option, because: Integrity: If we have different databases, we won't be able to create Foreign Keys between them. Avoid Sync: If we have different databases, we would have to create a synchronization mechanism, which is very prone to failures. Maintenance: Maintenance will be easier if we have only one database. No change will need to be replicated. Can you help me decide which way to follow, and why?


title: Encouraging software engineers to track time

text: How can I encourage my coworkers to track the time they spend resolving issues and implementing features? We have software to do this, but they just don't enter the numbers. I want the team to get better at providing project estimates by comparing our past estimates to actual time spent. I suspect that my coworkers don't see the personal benefit, since they're not often involved in project scheduling.


title: How to show someone of the power of model-view-controller design pattern?

text: I've been working with a friend on a project that we've taken over, and I've realized that we have a big problem implementing the model-view-controller design pattern due to the way that the project has been set up. The project is currently split up into the following three sections (.proj files in Visual Studio):   1. Model classes.   2. Controller classes (business layer logic).   3. View classes. Visual Studio isn't letting me create cyclic references (quite understandbly) between two of these three sub-projects. This means that the controller classes can have a relationship with the view classes, but the view classes can't have a relationship with the controller classes! The result of this is that as soon as the controller displays a view, the rest of the controlling logic has to go in the view class! So I've proposed that we merge all three sub-projects together (to avoid the cyclic references of visual studio). This means that we can create all the relationships between the three types of classes that the model-view- controller design paradigm requires. Ultimately, it will be we can place the controlling logic in the rightful place of the controllers, taking it out of the view classes. The problem is I'm having a hard time convincing my friend about this. He thinks that having these separate boundaries between the sub-projects means that there's safety that we won't ever do things like put controlling or viewing code in the model (as the model sub-project is currently only ever referred to and doesn't refer to the controller or the view). I was wondering if anyone could come up with some ways that I could really get my point across about how important this design pattern is, and how limiting it would be to go against it, and continue putting controller logic in the view classes? Many thanks.


title: Is there a difference in resource allocation & efficiency between a web app and a compiled one?

text: I'm a web developer. I feel like I develop less resource-intensive functionality often times, because I have this feeling that if I ask too much of the web app (animation, calculation, connections, etc), it will get lagged for users with slower computers. I've been curious for a while now about just how much difference there is in the capability (resource allocation) of a web (interpreted) app vs a compiled one. Also, I've heard that interpreted (JS, for example) programs are very inefficient and resource-hungry in comparison to compiled ones (C++, for example). Google's V8 JS Engine is said to make JS faster, but I still see people talk about JS being much less efficient than C++. * * * The reason that I ask this question is to separate fact from biased opinion.   * Is there a difference in available CPU & RAM between a web app and a compiled one?    * Is there a large efficiency difference between a program written in (an interpreted language) JS versus one written in (a compiled language) C++? * * * Edit: I realize that we are comparing apples and oranges here. There are some really well-defined aspects of choosing between C++ (anything compiled) and JavaScript (web) when developing a client application, and this is one side aspect of that decision that I would not want to be misinformed about if it were to come up at any point in my career.


title: How does team development work?

text: This is a pretty generic question but one I've been wondering about for a while: is there a standardized, generally accepted, or even just systematic way that people write code as a group? For example, in a project written in C++, does one developer write one class, which he passes off to the next developer with a quick explanation of what each method does?


title: license and copyright assignment

text: I'm currently working on a wordpress plugin. My client gives me a specs doc (a powerpoint presentation, if you can call that a specs doc), and I code the requested functionality. Every time I send him code every file containing code starts with these lines:               Author: My Name     Copyright: The_client's_company.com     License: MIT Expat (http://en.wikipedia.org/wiki/Expat_License)      My intention being giving my client complete right to relicense and distribute the code under any other license (as the TOS of the freelancing website requires, plus I know he intends to sell it under a proprietary license), but at the same time giving myself the right to expand and redistribute the plugin under MIT license if I wish to (not that I do). The reason is I am paid only 10USD/hour (this is my first gig) so I want to at least keep the right to reuse parts of the code in other projects or expand it if I want to start a similar project myself when I finish the contract (unlikely, but who knows...) or show it to potential employers. The contract we agreed upon doesn't include any licensing specifications but I've informed him on the emails we've interchanged that although all my work is licensed by default as MIT I'm giving my clients the copyright of the code I produce so they can relicense it at will before distribution. Is this the correct way of achieving that?


title: Are Blocks Second-Class Citizens in Objective-C (vs. Ruby)?

text: Feeling slightly witty the other day, I wrote an `eachWithIndex:` method in a `NSArray` category. It has a typedef like this:               typedef void (^processItem)(id item, int index);      and the method looks like this:               - (void)eachWithIndex:(processItem)block {         for (int i=0; i<self.count; i++) {             id item = [self objectAtIndex:i];             block(item, i);         }     }      However, if my block contains a `return` at any point, it doesn't jump out of the calling method (nor the block). Consider this code in Ruby:               def blah         %w{one two three}.each_with_index {|thing, i| puts "#{i}=#{thing}"; return "hello!" if i==1 }         puts "blah does more stuff"     end      when `i` reaches one, the `blah` method will end. This does not happen in Obj-C, and I feel that it should. Are blocks more integrated into Ruby than Objective-C?


title: What should I consider when deciding if I should use a web service backend instead of traditional MVC?

text: We're trying to decide what architecture to use for an upcoming web application that will eventually have a mobile portion as well. The core of the project is a social networking web application, and the mobile portion will most likely have a limited subset of the web functionality. The two options we are looking at is either a **complete web service back end** , or using a **traditional MVC framework** for the web application and then developing web services on the side for the mobile application later. Some arguments for web-service-only route is that it would be "simpler", as we would just have to create 1 web service as opposed to creating both a web service for the mobile portion, and additional database functions/calls for the web application. Using this method, the web application will fetch data from the web services using javascript, which would then generate the html page (sounds kind of like what a traditional MVC framework does, but this way would require everything to be done in javascript). I'm not feeling good about the idea of using web services only because it doesn't make sense to me, but I am having trouble clarifying my issues with it. So what should I consider when trying to determine if we should use a complete web-service backend for our project instead of traditional MVC with web services only available when needed for the mobile portion of the app? I'm looking for a comprehensive answer to this question, not many answers each containing one piece of the answer.


title: What is the most space efficient way to implement a graph data structure?

text: I typically implement graphs as doubly linked lists but this is fairly space inefficient in my experience as I need k pointers/references for k neighbors so for an undirected graph I'd have ~2k neighbor links within the lists if my math is right. Is there a better way of saving space? I know that some of the links can be made singular if the graph is directed but is there a way to do a better job of this?


title: Can/Should I put my Git repository on a non-dev machine and keep it synced with the non-version control server?

text: I volunteer for a website, and well, basically, we don't have version control. We're working to change that, but because of several things, including the fact that I haven't worked with source control before, that's not happening for some time. In the meantime, I'd like to move my working files into source control (probably Git) for the obvious benefits. Here's the thing: there are hundreds of thousands of files on the web server that are user-generated that I don't really want on my dev machine because, well, I pay for my own equipment (it is volunteer after all, so it's not like I can expense a new hard drive) and my dev machine is also my everyday computer and I'd rather not clog it up with a lot of stuff that doesn't need to be here. I do, however, have an empty system sitting around that is perfectly willing to store all of that data. In all likelihood, that system is probably going to host an entire local copy of the site anyway as a backup. So, and I hope this isn't an entirely crazy idea, I'm thinking about putting the Git repository on that machine. I'm not intending to develop on that machine, however. So,   * Is putting your Git repository on a different computer than your dev machine a really bad idea? It should be technically feasible as it's on the same network, and I don't think my IDE will have any problem connecting to it, but that doesn't mean it's a terrible idea. Putting the repository on my dev machine isn't out of the question, but it'd be preferable to put it on the empty one.   * (And I hope that this is related enough to keep in the same question) Because there are other people working on the site, changes are going to happen to the remote site that aren't going to go through source control. Since I'd prefer the two to stay synced, could I create a Git repository on the server, pull and merge changes into my local, and then just upload the changes through FTP? Doing any real version control on the server isn't feasible at the moment (as I said, it's being worked on), but a repository that we don't touch is a different matter. Would this be a feasible plan at all?


title: What do I need to do to NOT steal "Hello World" code with a GPL license?

text: In the project, I found a file, `math.c`, with a big GPL header and ...               //------------------------------------------------------------------------------     /// Returns the minimum value between two integers.     /// \param a  First integer to compare.     /// \param b  Second integer to compare.     //------------------------------------------------------------------------------     unsigned int min(unsigned int a, unsigned int b)     {         if (a < b) {             return a;         }         else {             return b;         }     }      OK, cool so I need to get min value and ... **_this file_**!? So I need to open the whole project because of it? Or do I need to reinvent mathematics? I don't believe it's just insane, so the question is: when we can just remove the GPL header? Must I _be a weirdo and do it_?:               unsigned int min(             unsigned int     JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE,     unsigned int hyrthrtRERG            ) {  if     (JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE     < hyrthrtRERG            ) {  return JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE;  }     else {return hyrthrtRERG            ;    } }      Seriously, do they want me to write code like the above?


title: Benefit of using static inner builder class

text: During the course of writing the code guidelines for a company I found myself recommending using the Builder pattern from Effective Java, instead of telescopic constructors. However, after thinking about it a bit more, surely a more elegant solution is to just remove the builder class and the also remove the extra constructors with optional arguments. So just have the one constructor with required parameters, normal getters/setters, and comment the code. When implementing just create a new instance of yr object then set values. My original thinking was the benefit came from removing the confusion as to what paramters were optional and what were required; however the true benefit comes from using method chaining/fluent interface. The builder pattern has benefits when you make lots of new instances as the ide can do the leg work and also if there are many (15+) optional parameters. However, is it worth the extra time coding the static inner class, would you recommend using the builder, or is it a waste of time ?


title: Can a beginner in programming start learning game development?

text: I'm very new to programming and I'm using Java. I got interested to learn programming because I want to create games. I love playing computer games and I know that game developers make money. I told myself that instead of just playing why not create my own game and probably make some money. I read some articles about game development using java and I learned about JMonkey. I just installed it in my Ubuntu PC. Should I learn first the basics of Java or I can start learning JMonkey and Java at the same time? I know that JMonkey is game engine built using Java and it provides libraries to help developers create Java games efficiently but its kinda advanced for a dummy like me.


title: Should you exercise TDD on prototype applications?

text: I'm developing an iOS app, which is a prototype for a customer. They're expecting it to not be of production standard and are happy for a few rough edges here and there. Since this is my first commercial venture into iOS / Objective C (I'm an android developer that is trying to cross-train into iOS), my primary focus has been learning the Objective C language and how to develop the app, and I have not invested any time into learning how TDD can be applied in this environment. My question is, even for prototypes, should you still try to apply TDD and create unit tests?


title: Is WCF suitable for writing an application which is shared among applications?

text: I have developed and deployed few ASP.NET applications. Sometimes I want to stop the users from either inserting or updating a record when:   1. Maintenance is going on.   2. Stop operations due to payment delay. In one of my recent application I have implemented this feature to first check the database operations for locked status. If any of the above condition fulfils, database operations like insert and update are not carried out. I now need this feature in all the old applications and the future applications I build. I want to know whether WCF is suitable in this scenario as I want to share methods or an independent locking application among various other applications. Is WCF appropriate for this type of scenario?


title: Is there any better approach to shortest path finding within a (vehicular) traffic network?

text: Dear fellow programmers, We're developing software which simulates vehicular traffic. Part of the process called "assignment" is concerned with assigning vehicles to their routes and has to use some kind of shortest-path-finding algorithm. Traditionally, people do this with Dijkstra's, and certain scientific literature seems to indicate that A* and other alternatives don't give any significant improvement, perhaps due to the nature of the graph. Hence, we're using Dijkstra's as well. A small problem arose in that, if you treat traffic links (spans of roads between intersections) as edges and intersections as nodes, you can't get a classic uni-directional graph: when approaching an intersection, where you can turn frequently depends on where you're coming from, whereas in a traditional graph you can take any edge from a node. We resolved this problem quite easily by representing a link-intersection pair (call it "lath") as a node. Since you'd need to traverse a link to get to any subsequent "lath", or point of choice, an edge would then be defined as this traversal, and you get a typical graph. The results then are stored in a simple table, N x N, where N is the number of "laths." Here's the (unavoidable?) drawback. If a typical network for our simulation can have, say, 2000 intersections, it will have somewhere around 6000 links, i.e. N = 3V. Obviously, if counted in terms of intersections (V), we're now up to O(log(3V)*(3V + E)). You might argue that 3 (or 9) is a constant factor, but from the practical standpoint, it does slow things down quite a bit, and increases storage space to 3V x 3V. Does anyone have any idea how we can restructure this to improve performance? Not necessarily any alternative algorithm, perhaps reshape the data structures to fit a graph in some other way?


title: Would this be considered dependency injection?

text: Would this be considered dependency injection, or delegation or object collaboration? https://gist.github.com/3428071