title: What do you call different user roles in software design?

text: I'm just curious, I'm building a web app with a User model which has role- based permissions. I have the following roles:   * Visitor (anonymous user)   * ?? (logged-in user)   * Moderator   * Admin I'm having a hard time figuring out what to call a logged-in user. I want to just call them "users", but I find that having a role with the same name as the class creates confusing code sometimes. For instance: `if user.user? then...` If you've built software with roles for users, what do you call the basic, registered, no special permissions, user role? _EDIT:_ As a side consideration, this app has Subscribers and Non Subscribers. Whether or not a user is a subscriber is not the same as their role, but it affects the way I've been thinking about this. For instance, calling a regular user a "member" sounds a lot like what I would call a subscriber, so I haven't been too fond of that. I haven't ruled it out though.


title: Explanation of the definition of interface inheritance as described in GoF book

text: I am reading the first chapter of the Gof book. Section 1.6 discusses about class vs interface inheritance: **Class versus Interface Inheritance** > It's important to understand the difference between an object's class and > its type. An object's class defines how the object is implemented.The class > defines the object's internal state and the implementation of its > operations.In contrast,an object's type only refers to its interface--the > set of requests on which it can respond. An object can have many types, and > objects of different classes can have the same type. > > Of course, there's a close relationship between class and type. Because a > class defines the operations an object can perform, it also defines the > object's type . When we say that an object is an instance of a class, we > imply that the object supports the interface defined by the class. > > Languages like c++ and Eiffel use classes to specify both an object's type > and its implementation. Smalltalk programs do not declare the types of > variables; consequently,the compiler does not check that the types of > objects assigned to a variable are subtypes of the variable's type. Sending > a message requires checking that the class of the receiver implements the > message, but it doesn't require checking that the receiver is an instance of > a particular class. > > It's also important to understand the difference between class inheritance > and interface inheritance (or subtyping). Class inheritance defines an > object's implementation in terms of another object's implementation. In > short, it's a mechanism for code and representation sharing. In > contrast,interface inheritance(or subtyping) describes when an object can be > used in place of another. I am familiar with the Java and JavaScript programming language and not really familiar with either C++ or Smalltalk or Eiffel as mentioned here. So I am trying to map the concepts discussed here to Java's way of doing classes, inheritance and interfaces. This is how I think of of these concepts in Java: In Java a class is always a blueprint for the objects it produces and what interface(as in "set of all possible requests that the object can respond to") an object of that class possess is defined during compilation stage only because the class of the object would have implemented those interfaces. The requests that an object of that class can respond to is the set of all the methods that are in the class(including those implemented for the interfaces that this class implements). My specific questions are:   1. Am I right in saying that Java's way is more similar to C++ as described in the third paragraph.    2. I do not understand what is meant by _interface inheritance_ in the last paragraph. In Java interface inheritance is one interface extending from another interface. But I think the word _interface_ has some other overloaded meaning here. Can some one provide an example in Java of what is meant by interface inheritance here so that I understand it better?


title: Wikipedia confusion about ExtJS

text: I'm looking at the wiki on ExtJS, the wiki on List of rich Internet application frameworks, and the wiki on Comparison of web application frameworks. I'm confused. The first line of the ExtJS wiki page says: > Ext JS is a pure JavaScript application framework for building interactive > web applications[1] using techniques such as Ajax, DHTML and DOM scripting. So I assume it's a web app framework. But in the right hand side summary box it says: > Type: JavaScript library Is ExtJS a web app framework or a Javascript library or both? (Can it be both?) ExtJS is also missing from the web app framework lists...       Thanks for reading


title: Inventory Management System Design Problem "Items Packages"

text: I am developing a retail management system with inventory management module, I am facing a logic design problem and I don't really know how to address the problem in an easy way, so I wrote an example which illustrates that problem: Let's say I have an item (e.g. Cola Can), this item have a Barcode (11...1), this is so good until now and we can sell the item smoothly using the Cola Can barcode(11...1). However, when the warehouse buys cola can they buy with larger package for simplicity 6 cans packages which have different barcode(11...2), after that the 6 packages is braked down into 1-1 cans and sold per item of barcode (11...1). The problem is that you buy with package and sell per item which will make the reports for the inventory incorrect, and the inventory stock will never match. How to control this packages problem or should the system deals with the smallest package only (e.g. when I buy 6 cans package, the warehouse should enter 6 items of single can barcode)?


title: Why do so many developers believe performance, readability, and maintainability cannot coexist?

text: While responding to this question, I began to wonder why so many developers believe a good design should not account for performance because doing so would affect readability and/or maintainability. I believe that a good design also takes performance into consideration at the time it is written, and that a good developer with a good design can write an efficient program without adversely affecting readability or maintainability. While I acknowledge that there are extreme cases, **Why do many developers insist an efficient program/design will result in poor readability and/or poor maintainability, and consequently that performance should not be a design consideration?**


title: Seperating business logic and layout in a highly interlocked project

text: My company is developing software that has a lot of technical debt that has existed for more than 20 years. It's a mix of C++ and C and consists of about 2M LOC. I would like to make some suggestions how we can advance our project and get rid of technical debt while using modern design principles. This application is heavily modularized and consists of more than 250 modules that can be viewed by the user. Those modules are designed with our own framework, an xml-file with all the layout, some business logic that is interpreted by the application and a c++ class with other logic. For example to create a mask with single grid that displays some data, we need to create the generic class-files that register our new module to the application, open our application in _designer-Mode_ , place a grid in our module and attach a sql-statement that fetches the data for it. If we would like to add some logic that is not possible with our _designer_ , we need to add some callbacks to our class and add those to our grid in the designer. Now the xml-file is filled with all the information our application needs to generate that module (i.e. where exactly the grid is, the ID, the attached callbacks and the sql to fill it). As you can see there is absolute no cut between design, business logic and the dependencies. There are of course two main advantages:   * many things can be done without recompiling the application   * small errors can be fixed by non-developers (like wrong SQL statements, name of labels, placement of the elements But I hope you agree with me, that this system could benefit a lot, but I'm not experienced to propose my own solutions. **What steps can I take to solve that problem in a realistic way thats acceptable for both us developers and management?**


title: How to obtain feedback for a project?

text: Software is easy to build, but even easier to build the way the developers think it should function. What about the end user? How best to obtain feedback from them regarding a new product? For example: we recently released a new web based application for IT support and this is what the user must use to receive IT support. They have no choice. How can we elicit feedback from them? Ideas outside the box are most appreciated because I find the usual feedback form gets few submissions so I am looking for creative ways to get in touch with our user base and continue to develop this application (or any in the future) with their desires in mind.


title: How should I create object after database insert PHP

text: I have just been working on a new project and doing things the same way I have for years now. However for the first time, I am constantly thinking about `scalability and performance` of both the `application code` and the `database`. So in times past, I have been more than happy to `insert` a new row, then grab the `last_insert_id` and then translate this into an `object` by calling the `getObjectById(id)` method from within whichever persistence framework is in use. I find this is good practice because it will ensure that you are returning exactly what is stored in the database and any error will be picked up there and then, rather than next time you ask for the object. The other way, since you have all the data required to build the object right in front of you, is to simply create the new object from the supplied data and simply set the `objectId` once the statement is verified as complete. I have always felt as though there are still some unknowns which can occur, and if there are any `triggers` in the database which transform the data in any way, then you will have a mismatch in state which is bad. However, thinking purely about performance, I am obviously taking a hit by running multiple `queries` to create the object (`insert` plus `select`) which adds `overhead` and I would like to make the application both as `fast` and `secure` as possible. My question is, what would be the most appropriate approach for `performance`, `scalability`, `security` and then for the trade-off between the 3?


title: Is there a better way of writing unit tests than a series of 'AssertEquals'?

text:
Here's a basic example of what my unit test needs to be, using qunit:               <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">               <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">     <title>Insert title here</title>          <link rel="stylesheet" href="qunit/qunit-1.13.0.css">

                Now I was thinking this is a bit repetitive. Could put all the inputs/outputs into an array, and loop through it.               test("Fuzz Query Basics", function()             {                 var equals = [                                ["name:(John Smith)", "name:(John~ Smith~)"],                                ["name:Jon~0.1", "name:Jon~0.1"],                                ["Jon", "Jon~"]                                ];                      for (var i = 0; i<equals.length; i++)                     {                         equal(fuzzQuery(equals[i][0]), equals[i][1]);                                    }                  }         );      And this works fine. The single advantage I can think of for this second method, is that if it turns out that you don't actually want to use `equal` it's easier to make that change in one spot. In terms of readability, I don't think it's conclusive either way, though I probably prefer the second. Abstracting it further, you could put the input/output cases into a separate CSV file, which might make it easier to modify. Question is - what are the general conventions around writing these kinds of unit tests? Is there a reason you shouldn't put them into arrays?


title: Using a CMS that I'm not familiar with just for the sake of the job?

text: I've been designing and developing with Wordpress for about two years (and I love it). Recently, a respectable designer told me that I could work for him. He works with Joomla! My job was to create a Joomla! template. I didn't feel myself comfortable using it. I don't like the back-end's UI, the way you add elements and content (I don't even like Joomla!'s logo). I'm used to simple interfaces and Joomla! seems too cluttered to me. That's why I started to wonder if I'm better off just finding clients and using the CMS that I love or making an effort to learn a CMS that I don't like using?


title: Programmatically syncing with remote servers

text: My application generates text files that need to be synced with remote servers, which may be windows or linux. Sync has to happen without user's intervention. I tried with rsync but windows doesn't come with rsync by default. Also it is not possible to supply password in the command line for rsync. Currently I'm going with ftp. But that seems like an inefficient way. Is there a way to rsync without user intervention? What are the ways to sync with a remote server programmatically? App is on nodejs.


title: Speed of MySQL type index access vs. binary jump search on a huge file?

text: I am dead set on moving over to a MySQL database for some huge data sets I'm working with but right now I don't have the time. In the meantime I am curious about a technical performance issue regarding speed between the two methods. Obviously binary jumping on a huge sorted file is a nasty hit to performance. The chances of finding the data you need in the chip cache or even memory is pretty bad if you assume a statistically normal distribution of record requests across the huge file. Unless the whole file is in memory, and some of the ones I am working with are 20GB so this is impossible on the Win32 system I am using, it's almost a certainty that a large number of record requests will degrade to the performance killing operation of an actual hard disk read. Since I have never done any database index programming other than some really simple B-tree indexing, I wonder how good the indexes created by modern databases like MySQL are at avoiding hard disk hits. Obviously one big advantage they have is if the index keys are a lot smaller than the data records they represent, you can jam a lot more of the index pages, if not all of it, into memory and that avoids a lot of disk hits. But I was wondering if the code behind those indexes can successfully optimize in other ways, especially when it comes to index page access prediction, to speed things up even more by making sure most index page accesses don't result in disk accesses? If anyone has had any deep experience with the kind of code underlying MySQL indexing or similar entities, or has done some deep performance testing, I'd like to hear about it. \-- roschler


title: Is anyone here Zend certified? Do they recommend it?

text: For the amount of web developer job interviews I've been to, I'm somewhat surprised that no one has brought up Zend certification. Has anyone ever been certified before, or is it a waste of time/money?


title: Code licensing / software licensing

text: I’ve been working on something outside of my day job and they have asked me if they can use it. It is a closed source project, but I don’t mind giving them the source code; but I definitely want to retain the intellectual property and any improvements they make. Is there a prewritten licence I could use for this? Has anyone got any experience of this situation? Update I decided to drop the “any improvements they make” bit. So I’m looking for a licence that has the following • The intellectual property to stay with me • they cannot sell the source code • but free to use it in all products and to make modifications I think if I modify the BSD license that will achieve this.... Copyright (c) 2011, (My Name) All rights reserved. Use of source, redistribution and use in binary forms, with or without modification, are permitted provided that the following conditions are met: • Source code must retain the above copyright notice, this list of conditions and the following disclaimer. • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. • The name may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. What you think?


title: Cost of maintenance depending on paradigms

text: Is there any data on which paradigms allow for code which is easier/cheaper to maintain? Certainly, independantly of the chosen paradigm, good design is cheaper to maintain than bad, but there should probably be major differences coming only from the paradigm choice. Unstructured programming, for instance, generates very messy code (spaghetti code) which is expensive to maintain. In object oriented programming, implementation details are hidden and thus it should be pretty cheap to change those. In functional programming, there are no side effects, thus there is lesser risk of introducing bugs during maintainance, which should be cheaper. Is there any data on which paradigms are the most cost-efficient when coming down to maintenance? If no such data exists, what is your take on the question?


title: Building web apps in server-side vs client-side vs hybrid?

text: There are currently multiple approaches for building web applications: ## 1\. Server-side only This is a classical approach where you render pages on the server by a web framework like Ruby on Rails, Django, Express, Play! Framework and etc. **Typical workflow** : Build all your business logic, models and view templates on the server in the framework of your choice. ## 2\. Client-side + REST API Relatively not too long ago, web community as a whole started to build client- side applications in Angular, Backbone, Ember, and a few dozen of other JavaScript MV* frameworks. And now we also have React.js join the party. **UPDATE** : There is no misunderstanding. What I meant by client-side only is complete separation of concerns. Your have a REST API server and a client-side application that talks to that server. Depending on your use case, chances are, you will never have a true client-side only application that doesn't connect to a back-end either for authentication or data persistence. **Typical workflow** : Spend hours deciding on Angular vs Backbone vs Ember vs X. Then you build your routes, models, views, controllers on the client. After you are done, now build models, controllers, routes on the server. In a way you are doing double amount of work. # 3\. Hybrid I don't know much about using this approach, but if I were to take a guess, you render your views (View of the MVC framework) on the server. As a result you get SEO support plus faster page loads. On the **Hybrid** front there is airbnb's **rendr** that supposedly combines backbone and express together. Eric Florenzo has posted on his blog today: React: Finally, a great server/client web stack. The amount of ways to build web applications is just overwhelming. And for someone who's learning web development this can become a problem. How does one decide on which approach to use in order to build their next application?


title: Would it be the right software engineering system to move from AngularJS-based to jQuery-based or hybrid implementation for webapp?

text: I am presently working on an AngularJS-based chat webapp, and it polls the server for updates, and then renders them in what is pretty much a straight shot in AngularJS. The result looks appropriate for the maturity of the project, but it completely shuts down clipboard copying from the dialogue because it redraws the text for each polling interval and overwrites the relevant area of the screen with the most newly polled data. I can see how to reduce this problem by more surgical DOM manipulations in jQuery, where there is one DIV for each completed chunk of data, only DIVs whose contents have actually changed are overwritten, and new DIVs are appended to the container rather than overall. And perhaps someone can point out how to make a more surgical AngularJS implementation so that updates to a small portion of the data rather than thrashing that area of the DOM when the data has been polled (`<div ng-repeat="contribution in contributions" ...>`). However, I wanted to ask for the appropriateness of my approach. AngularJS obviates most of the need for specifying low-level DOM manipulations; if something surgical desired, would a good AngularJS programmer shift to something like jQuery that's more intended to allow low-level DOM manipulations, or does AngularJS offer facilities for more surgical updates so that DIV's whose contents are static are not redrawn? I thought about asking this on StackOverflow, and it might be appropriate to ask there how to make a more surgical update so that if the user has begun selecting an area, things that are not going to be changed again don't get thrashed. However, I wanted to ask here. I know jQuery better than AngularJS, and it seemed appropriate to make a "Take a step back" question here about using AngularJS right. Would an AngularJS programmer who knew jQuery do it with jQuery, do it with a more surgical version of AngularJS usage, or do something else? How do programmers who think in AngularJS handle a situation where they need finer- grained control than the default version allows? Thanks,


title: Representing the hierarchy of groups of numbers using type inheritance

text: I've run into an interesting conundrum while coding my own implementations for the basic sets of mathematical numbers (Natural, Integer, Rational, Irrational, Real, Complex). I'm doing this mostly for fun, but also because I want properly represented numbers in code. It started off with RationalNumber. I added two fields to my class: Numerator and Denominator. I've overloaded all the basic operators that I am able to (I'm using C#) so that I can define what it means to add, subtract, etc.. for these objects. From here, I thought that I'd extend my definitions upward and make a `RealNumber` class such that this type can extend from it so that it could fill in for any RealNumber elsewhere in code... Except intuitively, the number system operates contrary to this definition. Illustrating what I mean, consider starting off with the basic natural numbers. We can "extend" the natural numbers to include negative numbers as well (and zero if you weren't already including it) and then we call this new group the integers. In code, this would imply that `Integer` inherits from `NaturalNumber`. If I wanted to write a method that accepts an integer parameter, logically one would assume you could use a natural number as well; but with the way inheritance works, this doesn't fly. How can I properly model the relationship between the sets of numbers through inheritance so that I can put a natural number into?


title: Why do VMs not execute the assembly directly?

text: Many VMs execute a language of binary form, knows as 'bytecode', which is assembled down from a human readable 'assembly' language. For example the assembly instructions `push 1 push 2 add` are translated (I think) to a series of ones and zeroes, which is then executed by the VM. Why? Why don't VMs, and the JVM as an example, execute the assembly instructions directly? They don't have the limitation of physical computers that can only handle ones and zeroes. The JVM can very well take textual instructions such as `push 1 push 2` and execute them as they are. Why the additional step of compilation?


title: How to structure my data model for merging of accounts

text: My new site will allow for 'normal' registration or the use of Facebook openauth. I have many tables that link data to a user_id. Imagine one of my users with information on my site forgets they used Facebook to create an account. They create a second 'normal' account and use the site for a while. So the user has data associated with two user_ids. I want to give them the option of "importing" the data associated with the first account into the newest account. This is messy, and I would rather design things right in the first place but I can't wrap my head around an elegant way to do this. Here are the options I have thought of:   1. Allow a user profile to have a master(parent?)_id, and write all of my db queries to select many user_ids. Upon a merge from one account to another, the losing account gets the winning account's user_id as it's parent_id.   2. The above, but cleaner: consolidate many logins into a lookup table   3. System-wide one time update: Find all data with user_id 1 and change it to user_id 2. This gets progressively harder as we store more data.   4. Merge with data loss- same as #3 but only crucial data. The user loses historical records etc. Or am I glossing over an easier way to handle the scenario I am trying to plan for?


title: Interview prep for coding

text: I have an interview for a position and was told that I would have to do some coding test, given a laptop in a specific, by myself, in a specific time- period of 45-60 mins.   This is the first time for me for something like this, and I was wondering how could I prepare best? Do you have similar experience?   What do this kind of tests are about?   Any example?


title: What is the session about simplicity that Martin Odersky suggested during the "Scala with style" talk?

text: The video of Scala with style is here: http://parleys.com/play/51c1994ae4b0d38b54f4621b/chapter21/about It's around 41:10 that he suggested another talk. I can not hear the name of speaker or the name of the session very clearly. Could someone help me to figure that out?


title: Looking to simulate the rolling of a ball around a roulette wheel, while the resulting number is already known

text: I want to make a roulette board with a ball spinning and landing on a certain field. The catch is that the field the ball will land on, is known beforehand. I want the animation to look somewhat realistic, even though the result is decided beforehand. So I think I need to calculate the path the ball will follow, starting from it's end position. However, in this case, it always needs to end up in the same starting position. How can this be done?


title: How to effectively define requirements on a complex project requiring collaboration from many people with less than great personal relationship

text: I am working on a project that is basically a rewrite of an old batch based system that now should run online. The old system is complex and poorly documented and best source of information are people that originally built it and maintained it. However, even they are often at odds about certain functionalities. What’s worse, they don’t get along very well between them or with the team, since the roles are not very clear, they are considered Product Owners, but feel that they should lead the project. I wonder what would be the best way to extract the information they possess. At this point I think (and I never thought I’d say that) that face-to-face meetings are not very productive. Maybe a tool that would implement a flow where they would all have to answer a question that team has would be appropriate. Or maybe a wiki? What would you propose?


title: Not using SQL Transactions

text: I am looking at a codebase where a developer never uses SQL transactions i.e. each update/insert into the SQL database is an atomic operation. I believe the codebase would benefit from transactions. I was looking online today and in one Stackoverflow question an answerer says: "In some situations it is better to have a partial update rather than none at all". Is there any truth in this? I suppose it depends on the problem domain to some extent.


title: Does any programming language use variables as they're in maths?

text: In maths, a variable means you can put any number there, and an equation will still be true:               root(square(x)) = abs(x)      In programming languages, this is not so: a var can change. In Python:               y = (x**2)**.5     x *= 2     assert y == abs(x)      will raise an exception, since x in the last line is not the same. Are there programming languages that use immutable variables?


title: career advice for PhD scientist seeking to program?

text: I'm largely a self-taught programmer. In fact, I first started programming about half way through biophysics grad school, and even though I think I've done some pretty nice work, I've never worked as part of a 'serious' development team that had more than one or two other developers (and I wouldn't hesitate to call them equally inexperienced in software development as a profession). After finishing my PhD I've kept focused on programming, officially as a postdoc, but unofficially as staff research programmer. In that time I've also had two interviews at Google, but not an actual offer. As it is I've put down some roots and probably would not have been able to take the job anyways. House + wife w/ very well paying job, etc. It's been about three years, and my honest assessment is that I've learned a ton more, but I really need more of a peer group to maintain or accelerate my growth. The problem is, whenever I look, most job listings have requirements that seem impossibly grandiose and I hesitate to apply. That, or the job/project seems incredibly dull. I suspect that either most people are just a lot less realistic than I am when it comes to assessing how long it will take for them to get up to speed, or they don't care; my fear is that I'm just woefully unqualified for any interesting, well paying developer work. IE: I'm confident I could switch fully back into C++ mode with a couple weeks work (I mostly use C,Python,C# daily) but I don't list myself as being 'proficient' in C++ on my CV, or applying for jobs that 'require' such knowledge. The few applications for which I did feel I was a legitimately good match have not elicited a response. I suspect the following things are potential problems with my application/CV and I would like feedback: I don't have a CS degree. My BS was in biochemistry and molecular biology, my PhD in biophysics. I took undergrad and grad level algorithms courses and completely killed them, but I don't know how to translate that to my CV effectively (the difference between getting an A+, and smoking everyone else in the class). I have a PhD, but it's not in CS... I've been debating if I should remove it from my CV, and wether or not it would then be misleading to list at least some of those years as some kind of 'programming' job (in many respects it was). I think there are sometimes strong stigmas associated with 'self-taught' programmers. I am certainly one of those. I even recognize that some of those stigmas hold a hint of truth, but I really do want to be an asset to a team. How do I communicate that even though I have been largely self-directing for ~8 years I can still take marching orders when needed? Do I just say so outright? Should I just become a lot less scrupulous about the whole process? anecdote: I have a friend who applied for positions where he completely fudged his qualifications to get past the first culling. He was much more honest and forthcoming about his actual qualifications when contacted and he still managed to get invited to a couple of interviews and even got some offers. His balls are larger than mine though.


title: Ways to organize interface and implementation in C++

text: I've seen that there are several different paradigms in C++ concerning what goes into the header file and what to the cpp file. AFAIK, most people, especially those from a C background, do: ### foo.h                class foo {      private:          int mem;          int bar();      public:          foo();          foo(const foo&);          foo& operator=(foo);          ~foo();      }      ### foo.cpp                #include foo.h      foo::bar() { return mem; }      foo::foo() { mem = 42; }      foo::foo(const foo& f) { mem = f.mem; }      foo::operator=(foo f) { mem = f.mem; }      foo::~foo() {}      int main(int argc, char *argv[]) { foo f; }      * * * However, my lecturers usually teach C++ to beginners like this: ### foo.h                class foo {      private:          int mem;          int bar() { return mem; }      public:          foo() { mem = 42; }          foo(const foo& f) { mem = f.mem; }          foo& operator=(foo f) { mem = f.mem; }          ~foo() {}      }      ### foo.cpp                #include foo.h      int main(int argc, char* argv[]) { foo f; }      // other global helper functions, DLL exports, and whatnot      Originally coming from Java, I have also always stuck to this second way for several reasons, such as that I only have to change something in one place if the interface or method names change, that I like the different indentation of things in classes when I look at their implementation, and that I find names more readable as `foo` compared to `foo::foo`. I want to collect pro's and con's for either way. Maybe there are even still other ways? One disadvantage of my way is of course the need for occasional forward declarations.


title: Career switch from high level to kernel programming

text: Currently I am employed as high level programmer doing some algorithmic & database stuff in C++. In my company there are programmers that are writing Windows kernel drivers (mostly software drivers not hardware). Recently I have read some materials about windows kernel programming and I realised that this type of programming that I am really passionate about (more than high level programming). I would like to switch to kernel programming but I need a plan to do this. I was thinking about asking a boss to move me to the mentioned project but in my company you cannot freely move between projects (there is a lot of pressure to become specialist in one field). I was thinking about changing jobs but there is one issue. Does my high level background disqualify me in becoming kernel programmer? Maybe I should not put on CV my high level jobs? Could you give some advice in changing my job?


title: Should I create an Enum mapping to my database table

text: I have a database table containing a list of systems relevant to the tool I am building, mostly in-house applications, or third-party systems we receive data from. This table is added to infrequently, approx every 2 months. One of these systems is Windows itself, which is where we store our users' LANs, and I now need to explicitly reference the ID relating to Windows to query for user name, team etc. I know it would be bad practice to embed the ID itself into the code, so my question is what would be the best way to avoid this? I'm assuming my options are:   * create a global constant representing this ID   * create a global enum containing all systems now   * create a global enum and add systems to it as & when they are required in the code   * retrieve the ID from the database based on system name I appreciate this may seem a trivial question, but I am going to have many situations like this during the course of this build, and although we are in complete control of the database I would like to conform to best practice as far as possible. Many thanks!


title: Finding possible positions for rectangle in a 2-d array

text: Well, the title is not very appropriate, please read on (I couldn't get a better one). Note: Using Python 2.7, but an algorithm will help too. I'm making a side scroller game, in which I am generating the obstacles on the fly. The trouble I am having is figuring out how to generate the obstacles. o_O   I have a some kind of a logic, but then I'm having trouble in figuring out the entire logic. So here's my problem from an implementation perspective :   I have a `Surface`, in which I have put some `Element`s, which are all rectangles.   Think of it like:               0 0 0 0 0 0 0     0 0 0 0 1 1 0     0 0 0 0 1 1 0     0 0 0 0 1 1 0     0 0 0 0 0 0 0     0 1 1 0 0 1 1     0 0 0 0 0 1 1      As in the above structure, how can I determine if a `axb` rectangle can be added without overlapping another rectangle (of 1s), and where all. Also, that with maintaining a distance of x elements (even diagonally) from all the other objects, that means the entire rectangle is (x+3, x+4). Something like if `x=1, a=3, b=4`, there's only one possible arrangement:   (2s represent the new object)               2 2 2 0 0 0 0     2 2 2 0 1 1 0     2 2 2 0 1 1 0     2 2 2 0 1 1 0     0 0 0 0 0 0 0     0 1 1 0 0 1 1     0 0 0 0 0 1 1      Basically, I need to find all the points, from which an rectangle of sides `a` and `b` can have it's, say, top-left corner. How this be achieved? Note: Open to better ideas for generating the obstacles on the fly! PS: Am I unclear?


title: does this model-pattern have a name?

text: A few years back, I wrote this answer to a question from which the following idea emerged. I call these "Type Descriptors", as I have never been able to find this pattern documented or formally described anywhere - not to be confused with type descriptors in C#, but it's the most accurate name I've been able to come up with, so bear with me. Here's my first attempt at a "formal" description: > A Type Descriptor is a type that provides meta-information about another > type. > > This pattern can be seen as an alternative to run-time reflection and > annotations, and as such is equally applicable to languages that do or do > not support reflection or annotations. > > Type Descriptors are particularly useful as a means of describing aspects of > model types found in for example domain and view-models, as well as in > specialized types of models, such as form-models in a business- or web- > application. Often such applications have many common aspects, such as the > need to label inputs and perform common validations for e.g. required input, > data types and formats, etc. - the information required by helper objects > (or services) to handle these aspects fits comfortably in descriptors. > > A descriptor mirrors the shape of the type it describes - for example, if a > model type User has properties like id, name and email, it's type descriptor > must have properties id, name and email, but where the properties on the > model type have various value types (in this case for example integer and > string) the properties of the descriptor are objects that provide > information about those properties. > > Maintaining identical model type and descriptor shapes may seem like > duplication, in terms of property-names being identical in the model type > and type descriptor - however, this does not violate the DRY principle as > such, since the model type and descriptor, strictly speaking, are two > different types that only happen to have the same shape, but do not have any > overlapping concerns or duplication of any code; only the property names are > duplicates. I program mostly in PHP on a daily basis, and have used this pattern successfully to build applications. The following example is in PHP, though this could be implemented in any language capable of resolving properties by name at run-time. A tiny bit of framework is required to implement this, so here goes... A model-type implementing the following interface can provide a "type descriptor" - a type that describes the model-type itself:               interface TypeInfo     {         function getType();     }      Individual model-properties are described by "property descriptors" in the "type descriptor", for which I use a base class along the lines of this:               abstract class PropertyInfo     {         /** @var string */         public $name;              /** @var string */         public $label;              public function __construct($name)         {             $this->name = $name;         }     }      From this class, I derive "property descriptors" for specific types of properties - for example, this type describes a string property:               class StringInfo extends PropertyInfo     {         /**          * @var int|null          */         public $max_length;     }      Now here's a sample `User` model, and it's "type descriptor" `UserType`:               class User implements TypeInfo     {         /** @var string */         public $name;              /** @var string */         public $email;              /** @return UserType */         public function getType()         {             return UserType::instance();         }     }          class UserType     {         /** @var StringInfo */         public $name;              /** @var StringInfo */         public $email;              public function __construct()         {             $this->name = new StringInfo('name');             $this->name->label = 'Full Name';             $this->name->max_length = 50;                  $this->email = new StringInfo('email');             $this->email->label = 'E-mail Address';             $this->email->max_length = 128;         }              /** @return self */         public static function instance()         {             static $instance;                  return $instance ?: $instance = new static();         }     }      As you can see, it's now possible to get the type descriptor either from a `User` instance by e.g. `$user->getType()` \- notice that the property-names of the "property descriptors" in the "type descriptor" match the property- names in the actual model; using this pattern, it's my own responsibility to make sure the model and it's descriptor have the same shape. Now I can write services and helpers etc. which may consume information from a "type descriptor" while working with model objects - for example, here's a very simple form helper:               class FormHelper     {         /** @var TypeInfo */         public $model;              /** @var string */         public $prefix;              /**          * @param TypeInfo $model          * @param string     $prefix          */         public function __construct(TypeInfo $model, $prefix)         {             $this->model = $model;             $this->prefix = $prefix;         }              /**          * @param StringInfo $prop          *          * @return string          */         public function text(StringInfo $prop)         {             $name = $prop->name;                  return '' . htmlspecialchars($prop->label) . ''                 . '<input type="text" name="' . $this->prefix . '[' . $name . ']"'                 . ($prop->max_length ? ' maxlength="' . $prop->max_length . '"' : '')                 . ' value="' . $this->model->$name . '" id="' . $name . '" />';         }     }      You would use the form helper like this:               $user = new User;     $user->name = 'Rasmus';     $user->email = 'rschultz@gorges.us';          $form = new FormHelper($user, 'user');          $t = $user->getType();          echo $form->text($t->name) . "\n";     echo $form->text($t->email) . "\n";      Which would output something like this:               Full Name<input type="text" name="user[name]" maxlength="50" value="Rasmus" id="name" />     E-mail Address<input type="text" name="user[email]" maxlength="128" value="rschultz@gorges.us" id="email" />      The two key reasons I enjoy working like this are (1) patterns like rendering forms, mapping post-data to model objects, mapping model-objects to database records, performing input validation and so forth can all be performed by formal helpers and service objects, all of which consume the same single source of information, and (2) everything is "statically typed", meaning only a single unchecked property-reference (by name, as a string) is made and encapsulated inside the "type descriptor", and type-hints and inference in a modern IDE (PhpStorm) can provide automated code inspections at development- time, I can safely use automated refactorings, and so forth. Okay, a rather lengthy discourse, for what boils down to one question: does this pattern have a name? :-) Side question: does this constitute (reflective) meta-programming? (The use of this pattern is very similar to e.g. using reflection to obtain annotations from a model, though I find this to be much safer, less complicated, more flexible and transparent.)


title: Why is mod (%) a fundamental mathematical operator in many programming languages?

text: Is there a reason, historical or otherwise, why the modulus operator is part of a small set of standard operators in what seems like many languages? (`+, -, *, /` and `%`, for Java and C, with `**` in Ruby and Python). It seems strange to include mod as a "fundamental" (not to knock it, I use it plenty, but I also use exponentiation, absolute value, floor/ceiling or others -- they seem just as useful and necessary). Was this an old decision made in some specification which Java, C, Ruby and Python all follow or a language they are all descended from? As far as I can tell most Lisp dialects only include `+, -, /` and `*`. At first I wondered if mod was particularly easy to implement at the binary level (would that even make a difference, regarding decisions about what should be a "fundamental" operator and what shouldn't?) but it seems not to be. Is it just much more commonly used in programming than I think?


title: I'm thinking to CSRF protect all public AJAX requests that return JSON, but I have some concerns

text: I'm thinking to CSRF protect all public AJAX requests that return JSON, because what's to prevent another site from spoofing the AJAX header and using the JSON as if it were a public API? I think CSRF protection is the best solution for this, **however I'm concerned with the way Laravel handles this** :   1. Using laravel's CSRF filter, I notice in _app/filters.php_ that it checks using `Session:token`, will this require every public visitor to have a session and put additional requirement on server RAM (as opposed to browsing without sessions).   2. In the CSRF filter, Laravel checks `Input::get('token')`, but I may want to make POST ajax calls as well. Are POST requests not going to work?   3. What if a visitor has a window open. They walk away for a bit...then return to perform an ajax request. This would be a problem and we would need to refresh the page, which would seem awkward for a public visitor (as opposed to logged in users, where we could just redirect to a login page).   4. What if a visitor (or even logged in user) has 2 windows open? They walk away and let the session timeout. Then return and refresh one window (or login in again in one window), then go to the second window to perform an operation (only to find it doesn't work or they are forced to login again). **Can anyone address these concerns in Laravel's implementation of CSRF protection?**


title: As a programmer how do I plan to learn new things in my spare time

text: I am a Asp.Net/C# developer, I develop few projects in my spare time. I try to utilize my time as much as I can. I have been working for past 7 months. Suddenly these days I am a bit worried about learning the new stuff that is there for me as a programmer. I develop in my spare time so I don't get enough time to read books or blogs. So my question to some of you guys is how should I plan to learn new things, should I at least dedicate two-three evenings for new stuff, maybe ebooks while travelling is a good option too. How do you people plan to learn,should I also start to develop with whatever I learnt? As far as learning is concerned, should I just pick up the basics and then implement it or I should seek deeper understanding of the subject?


title: Which GOF design patterns work well with TDD, and which do not?

text: The GOF Design Patterns book rarely mentions the test-ability of each pattern. I'm aware that there are patterns such as Singleton that would lead to code for which it is difficult to write unit tests, and some such as Strategy that help with TDD. Which patterns promote TDD, and which hinder TDD?


title: Devise and Warden

text: I've been using Devise for a little while, and I've realized it's built on something else called Warden that handles authentication. What does Devise offer me outside of Warden, because I was considering removing devise and just using Warden.


title: Experience vs. versatility

text: Let's say a .NET programmer works at a company which provides software on demand, not as a product. The programmer works in WPF for a period of time and he/she invests lots of time in it. He/she get very good at WPF and Windows Forms and desktop development in general. But the company has to provide a web application now, so the developer has to learn MVC or Web Forms. He/she is not experienced in web development so he/she starts investing time in this new technology and in time they get good at it. But this time the company has to provide a Sharepoint solution, and so on. What is more important:   * Being very very good at a certain technology,   * Or be as versatile as possible knowing less in each technology but covering a greater area of expertise? Should the programmer keep studying and working in WPF until he/she reaches a guru level or is it a good thing that they had to learn other technologies as well? I agree with those of you who will say that when learning different technologies you will also learn things which are useful no matter the technology you're programming in. But eventually, when the programmer will want to change jobs, will it matter more that he/she knows _some_ WPF, MVC or Sharepoint than the fact that he/she is insanely good at one of them? I would think the second one is more important since most companies are looking for a developer for a certain technology. I don't think there are many companies looking for technical know-it-all people. What do you think?


title: Lisp/Clojure: Removing unnecessary parentheses through conventions

text: I am fascinated to Lisp as it is `simple yet powerful`. I am just a beginner and I know there have been lots of discussions on removing parentheses from Lisp and its dialects. Yet I request Lisp ninja's to take few minutes answering this. Will there be any side effects in Lisp/Clojure if they had followed 2 conventions below:               ;; function declaration     defn function-name param-1 .... param-n       ...       function-body ;; not (function-body)       ...          ;; function call     function-name param-1 ... param-n ;; not (function-name param-1 ... param-n)      While still using `()` or `[]` for inline and nested expressions.               (println "hello, ") (println "world !!!") ;; inline         = a (- 2 3) ;; nested


title: What is the simplest/easiest way to display line of text only when printing a webpage using PHP?

text: I have a line of text I would like to display only when a webpage is being printed. Is it possible to only display this line when printing the page or doing a print preview using PHP in some way? Basically, I want to print a page without the print headers, but would like to include the page's URL within the page's content when it is printed.


title: Implementation/Representation of Symmetries in Chessboards

text: In a 8X8 chessboard, I was wondering how to implement the symmetry of the board. A lot of positions are just **mirrors** or **rotations** of one another (with no pawns or castling capabilities left the directions are indistinguishable). By using a combination of **vertical, horizontal** and **diagonal mirrorings** of the board it is always possible to fix the position of a piece within the `a1-d1-d4` triangle. How to implement these symmetries on chess board? How does implementation depends on choice of board representation chosen(Bit-boards, 0x88, 8x8 array, and so on) ? **Edit 1:** The main goal is the implementation of the endgame engine generator and compress its results


title: Should UML be used before or after a basic Program Design

text: UML Diagrams take time and even though they provide knowledge about program design, the design changes and so do requirements, and hence it becomes a chore to keep UML Diagrams in Sync with code. I am trying to figure out how should we use UML in an optimum way.


title: Confusion about instance in an interface

text: I'm trying to learn OGSi framework (Equinox distribution). I have registered my service, but I'm confused about a piece of code that I've copied:               IAgendaService service = new AgendaService();      What does this line of code mean? I think that in the service object, there are the `IAgendaService` methods that I've implemented in `AgendaService`, but I' m not sure about this. Could it be a sort of upcating? (I know that it can't be because there is no inheritance, but I try to find something similar to compare)


title: What license shall I use for derivative (ported) software originally licensed under Mozilla Public License v2?

text: Currently I'm trying to port one tool fron Java to .NET and original Java tool is licensed under Mozilla Public License v2. Shall my port have the same license or can I apply different open source license? Most of code of the tool's was converted automatically using Java to .NET code converter.


title: How do I "ease into" programming coming from a designer background?

text: Is there a way I can 'ease in' to programming. Like learning to use/modify CGI scripts to add some functions to a basic html site? Even if it's the only thing I learn it's still useful, right?. Unlike starting on page one of an O'reilly Python book, it might be a year before I'm useful or I find out it's not for me. I'm a designer by trade (not a programmer) but more and more I build sites on php driven apps like wordpress and joomla. Or sometimes I have a basic html site and I want to add a form or some small app. I've simultaneously become more and more interested in interactive functions and the 'gears' of processing so I am considering dabbling in some scripting languages (php, javascript, cgi) or even some high-level languages like perl, python or ruby. But there is part of me that's saying "what the hell are you doing here? There is a world of programmers in a universe of syntax. You'll get lost before you are useful so just hire a programmer and go learn piano, do some volunteer work or something else useful." But there is another side of me that say's "hey wouldn't it be great if I could just plug in a simple process here an get this little job done." Can anyone recommend an insightful approach or should turn back now and just pretend programming never existed? Is Python a suitable starting point?


title: Can i sell my own software that uses parts of PSEXEC

text: I just have a quick licensing question about PSEXEC by sysinternals. As some of you may know if you have ever used PSEXEC, it is confusing to learn at first. I have created a program that makes it easier to use, and was wondering if I am allowed to sell that program (even if PSEXEC is included with it?). I looked in the sysinternals license agreement, but couldn't really find the answer to my question. The agreement is here: http://technet.microsoft.com/en- us/sysinternals/bb469936 The main download and info page for PSEXEC is here: http://technet.microsoft.com/en-us/sysinternals/bb469936 Please let me know if I will be allowed to sell my program. (I assume i am on the right stackexchange site, but let me know if I should move my question) Thanks!


title: Next language? Something practical but off the beaten path?

text: I've been itching for a while to learn a new language. I cut my teeth on PHP, though I don't use it anymore. I primarily program in D and Python now. I feel that these languages complement each other well, because D is close to the metal, statically typed and bleeding edge, while Python is more dynamic, interpreted, more mature and has better library support. I also know C pretty well (mostly learned from using the C-like subset of D), have some knowledge of C++, and have written a few very small one-off programs in Perl and Java. The key things I want in a langauge are:   * A language that significantly expands my horizons. I don't want to learn something that doesn't teach me anything conceptually interesting relative to D and Python.   * A practically oriented language. I absolutely, 110% refuse to spend any effort whatsoever learning a language that feels academic and emphasizes purity over practicality.   * Something that is mature, modern and well supported enough to use for real work. This doesn't necessarily mean large production projects, but at least serious prototypes and research code.   * Good generics, templates, duck typing, type inference, or something similar to avoid the rigidity of plain old static typing is a must.   * Terseness and readability count, though these are admittedly subjective.


title: What are use cases and advantages of pointers?

text: I often struggle to see the advantages of pointers (except for low level programming). Why use of char* instead of a String or char[] or what advantages pointer arithmetic brings. So what are the pros and use cases of pointers?


title: wizard-like data collection implementation help (next, next, finish)

text: I'm beginning to build an interface for our field techs to close out work orders and we have many different required paper forms for different customers. I had hoped to build a system where i can set up a Page for each form (all in .Net 4.0/wpf and possibly using caliburn.micro if it's not a bad choice), and based on rules, display certain pages automatically. I've started out by setting up a basic framework consisting of a wpf form with 3 buttons (back, next/finish, cancel) and a Frame. In the end i hope to have an object i can pass an identifier that will go get all the information it needs, decide which pages to show, show them in order, and update our database when the user clicks finish. Is there anything specific i should be researching/learning to make my job easier, or my finished product more robust/reliable? What would be a good approach to decide which pages to show? Mostly it would be based on something like `Show this form if Customer is X` but i'd like to be able to be more complex(extensible?) than that if i need. In the end, each page/form will probably also generate a PDF file of the customer's actual form, filled in. Sounds like a routine thing to have, but i've never personally implemented or used anything that did it, myself, so i'm going in blind. would the hosting window ask the page if they need to be shown? should the pages speak up themselves? should the hosting window pass the entire data object to a bool function `ShouldIShowYou()` and let the page sort it out? there has to be some mechanism already in place for me to "register" a page as being for a certain "something," but i'm not sure what it is. I'd like it to be fairly easily updated, but the app is deployed via clickonce and total number of users will be under 100 for the foreseeable future. just adding a new page object + logic to the collection and re-deploying shouldn't cause trouble. a few other questions i had:   * could(should) i implement this as a transaction in .net, where i could start a transaction when the window/object is created, have each individual page in the frame do it's own data work (via a shared wcf proxy), then commit the transaction after everything works out?   * should each page just build up an object and the main window pass the object back and have the originating application do the data work? e.g. make the whole segment of the application be data-unaware. not sure this would work out very well, sounds like a maintenance nightmare.   * is this the wrong place to put this kind of question? i'm not looking for code, so it didn't feel right in overflow. this is more of a "what are the words to describe what i'm trying to do" question. Thanks! i'll re-read this 10 or 12 times over the course of the day and try to clarify if i can. My brain-speak don't always make gud words.


title: Understanding the difference between mutable and immutable classes

text: I faced this question in one interview. I explained that `String` is immutable and `StringBuffer` is mutable class. I don't know very much about mutable and immutable and also don't know the exact answer. What are the key concepts to be able to distinguish the two ideas? Is there a performance impact when chosing one over the other?


title: is it bad that I have no html, or javascript in my php files

text: I have been writing my website, front-end: html, JS, jquery and css, back-end: php mysql. However my php files only contain php and mysql code. Is this a really bad thing? In what situation should PHP files contain html/javascript?? Currently my php files are just there to receive request and response with array of information. I just dont understand why people would put front-end stuff in back-end, is it for security?


title: Better use on the name of variables

text: I have a method that looks like this:               Public Function NormalizeStreetAddress(country As Namespace.Country,                                            streetAddress As Namespace.StreetAddress) _                                        As Namespace.StreetAddress                  Dim _streetAddress As New Namespace.StreetAddress = streetAddress                  If My.Settings.Streeteable = True Then                 Dim _AddressCustom As New Namespace.AddressCustom                 _streetAddress = _AddressCustom.NormalizeStreetAddress(country, streetAddress)             End If             Return _streetAddress     End Function      I receive a streetAddress object, but inside the method I need to use another streetAddress object which I called _streetAddress — is that following the standard? A friend of mine told me that object names such as _yourNameObject are for global variables, but I can't find info about this and I want to make this method more readable.


title: Naming boolean field that is a verb

text: In Java, by convention getter and setter for boolean fields will be `isField()` and `setField()`. This works perfectly fine with field names that are adjectives like `active`, `visible`, `closed`, etc. But how do I name a field that has meaning of a verb, like `haveChildren`? Add _ing to the verb (havingChildren), maybe? Edit: to clarify, I don't have control of the method names (getter and setter), they are auto-generated by the IDE. So what I need is an appropriate field name so that when the IDE generate a getter for it, it make senses. For example, hasChildren is a perfect field name, but when the IDE generate the getter for the field it would be isHasChildren. How do I solve this?


title: Combating the Einstellung Effect

text: The Einstellung Effect refers to "a person's predisposition to solve a given problem in a specific manner even though there are "better" or more appropriate methods of solving the problem." As a programmer with a decent amount of experience, how can one combat this tendency to always approach problem solving from "tried and true" paths from past experience? To give two very concrete examples I have been building web applications for a long time, long enough to predate wide use of Javascript frameworks (e.g. jQuery) and better web application frameworks (e.g. ASP.NET MVC). If I have client work where I am under a time crunch or pressing issues from the problem domain or business rules, I tend to just use what I know to try to achieve a solution. This involves very ugly things like               document.getElementById       or using ASP.NET with template bound controls (DataList/Repeater) rather than figuring out how to rearchitect things with an ASP.NET MVC approach. One technique I've used in the past is to have personal projects which exist simply for exploring these new technologies but this is difficult to sustain. What other approaches could be recommended?


title: Differences between Direct, Composition, Aggregation, and Temporary Association

text: I am looking to take my java certification very soon, and I have a question about the different types of associations described in the official oracle guide book. The book describes the 4 as the following:   * Direct = "has-a"    * Composition = "composed-of"    * Aggregation = "part-of"    * Temporary = method parameters or local variables inside a method etc.. I understand the examples they provide, but when shown a piece of code I can never figure out why it is one type over another. To further my frustration these don't seem to be common terms in uml diagrams and composition or aggragate is usually described as a "has-a" relationship depending on where you read. Here is a link to the book. http://www.amazon.com/Programmer-Study- Guide-1z0-803-Oracle/dp/0071789421 Pages 386-388 describe the different associations. Code examples would be very helpful.


title: Senior project environment selection

text: My 2 friends and I are preparing our senior project idea for next year. I need some of different ideas while deciding the base environment of the project, especially from software developers/engineers who worked in huge software product developments.   * We have limited human resources ( _just us, 3 students_ ), limited time and very limited fund.   * The project aims to office environments like Outlook, Thunderbird.   * It will run on the desktop, not web   * GUI will be really rich with customized widgets/dialogs like Outlook   * We want to start selling it and opening maybe a small company. So it is not just a senior project for us and we take it serious.   * Even if we can't open a company, we want this project to be a good reference at our CV, especially for when searching jobs in USA.   * Speed of the software is of course important, but realiability _(crashes in a commercial software product is not acceptable for customers right?)_ and bringing the project to a usable state as fast as posible are more important.   * It will be like MS Outlook, with many features in the single client. _(More than Outlook actually if we count.)_   * Also we want this project to carry our practical skills to a better place   * We use C++ and Java really good, but we never worked within a large project like this so we can't see how the environment effects our needs in the long term We have two environments to choose from (Java Swing and C++ Qt) and we are proficient in those, but because of the factors I described above, we should decide which one is better. **What would be your advise for a project with those criterias?** * * * **Our fears for Java:**   * Slowing the software because it is really a big project.   * Especially we are afraid of the GUI's speed. **Our fears for C++:**   * Developing time consuming   * Definitely more bugs will occur   * More time or money to develop and maintain _(harder to find good C++ developers than Java developers right?)_   * Making that much customized GUI with Qt might be really hard   * Libraries won't be reusable for a mobile web interface _(at least easily)_ _PS: It is not an email client. It will be used in office environments like Outlook, but not as an email client. Outlook is a good picture to represent it._


title: Write own messaging system vs. utilize existing ones

text: We are trying to have our own startup, with a middleware application to glue small applications with enterprise legacy systems.   for such middle-ware to function properly, we will need some sort of messaging system to make different components talk to each other in a reliable way. the alternatives are:     * use an existing messaging system, such as 0MQ, jBOSS, WebSphere MQ, etc.   * build our own messaging system the way we see the problem I am more biased towards the later option for the following reasons:   * to have more control over our final product   * to avoid any licensing problems later on   * to learn about messaging while writing the code   * to invent something new, that might cost us lots of $$$ if reused an existing system What would you do if in my shoes?


title: Dynamic Class Inheritance For PHP

text: I have a situation where I think I might need dynamic class inheritance in PHP 5.3, but the idea doesn't sit well and I'm looking for a different design pattern to solve my problem if it's possible. ## Use Case I have a set of DB abstraction layer classes that dynamically compiles SQL queries, with one DAL class for each DB type (MySQL, MsSQL, Oracle, etc.). Each table in the database has its own class that extends the appropriate DAL class. The idea is that you interact with the table classes, but never directly use the DAL class. If you want to support a different DB type for your app, you don't need to rewrite any queries or even any code, you simply change a setting that swaps one DAL class out for another...and that's it. To give you a better idea of how this is used, you can take a look at the DAL class, the table classes, and how they are used on this StackExchange Code Review page. To really understand what I'm trying to do, please take a look at my implementation first before suggesting a solution. ## Issues The strategy that I had used previously was to have all of the DAL classes share the same class name. This eliminated autoloading, so I had to manually load the appropriate DAL class in a switch statement. However, this approach presents some problems for testing and documentation purposes, so I'd like to find a different way to solve the problem of loading the correct DAL class more elegantly. **Update to clarify the issue** The problem basically boils down to inconsistencies in the class name (pre-PHP 5.3) or class namespace (PHP 5.3) and its location in the directory structure. At this point, all of my DAL classes have the same name, DBObject, but reside in different folders, MySQL, Oracle, etc. My table classes all extend DBObject, but which DBObject they extend varies depending on which one has been loaded. Basically, I'm trying to have my cake and eat it too. The table classes act as a stable API and extend a dynamic backend, the DAL (DBObject) classes. It works great, but I outsmarted myself and because of the inconsistencies with the class names and their locations, I can't autoload the DBObject, which makes running unit tests and generating API docs impossible for the DBObject classes because the tests and docs rely on auto-loading. Just loading the appropriate DBObject into memory using a factory method won't work because there will be times when I need to load multiple DBObjects for testing. Because the classes currently share a name, this causes a class is already defined error. I can make exceptions for the DBObjects in my test code, obviously, but I'm looking for something a little less hacky as there may future instances where something similar would need to be done. ## Solutions? Worst case scenario, I can continue my current strategy, but I don't like it very much, especially as I'll soon be converting my code to PHP 5.3. I suspect that I can use some sort of dynamic inheritance via either namespaces (preferred) or a dynamic class extension, but I haven't been able to find good examples of this implemented in the wild. In your answers, please suggest either an alternate pattern that would work for this use case or an example of dynamic inheritance done right. Please assume PHP 5.3 with namespaced code. Any code examples are greatly encouraged and I'm definitely open to different approaches. The preferred constraints for the solution are:   * DAL class can be autoloaded.   * DAL classes don't share the same exact same namespace, but share the same class name. As an example, I would prefer to use classes named DbObject that use namespaces like `Vm\Db\MySql` and `Vm\Db\Oracle`.   * Table classes don't have to be rewritten with a change in DB type.   * The appropriate DB type is determined via a single setting only. That setting is the only thing that should need to change to interchange DB types. Ideally, the setting check should occur only once per page load, but I'm flexible on that. ## Final Update Thanks to NikiC's suggestion, I created an abstract factory class that loads the proper DBObject and then wraps its public methods on a 1:1 basis. The table classes now extend the factory instead of the DBObject class. This setup will now allow me to test and use each DBObject class without worrying about conflicts and it lets me use multiple DBMS's at a time. It also allows me to retain the code hinting in an IDE for each table class because they each extend the factory wrapper. Using wrapping methods may not be the perfect solution, but it doesn't rely on dynamic class inheritance, it solves my design problem, it meets my requirements, and it works.


title: How can I get my website's search results into Google's search results?

text: All I can find online is stuff about search result rankings, which I'm not concerned with at the moment. We're going to have a cloud-based online database and we want Google search results for something relevant to our site to display our website's search results for the same query. For example, if someone types in "lunchbox" to google, there might be a result that says "Amazon search results for 'lunchbox'" and then you click that and it takes you to amazon, and it's already searched 'lunchbox' for you. What can we do to enable this capability for our site?


title: In a large statically-typed software project with non-dynamic manual sql statements inside of it, how do you verify all the sql syntax?

text: One of the things I seem to struggle with frequently is the need to deploy a software application to test the database interaction. More often than I'd like, I have a syntax error or typo in my sql statement that triggers a runtime error when the statement is invoked. In some of these projects, there is a very large number of sql queries (>100), which makes it very time consuming if I need check each one. Also, deployment and runtime steps can be so time consuming that it slows me down when checking sql I modified. Most of the time after checking out an unfamiliar codebase or one I haven't touched in some time, it is taken on faith that all of the sql works correctly. What are standard practices around verifying database interaction in applications in a non-manual\more automatic fashion?


title: API - How to handle scope based functionality?

text: > TLDR; > > Where and possibly how should I implement scope based logic in the example > code? I have got a ASP.NET Web Api. The Api uses OData (on top off REST) for data endpoints and OAuth 2.0 authentication. Now I want to add functionality to handle an Access Token in several different scopes. Some of the scopes are:   * User   * Organization   * Customer The result set the API returns should be based on this scope. The same applies if someone wants to add, update or delete an entity. **Now take for example the following endpoint:** `http://myapi/Employees` Someone with a Token in the _Organization_ scope does a GET and should only get the employees that are in the Organization that is defined within the Token. An user in the _Customer_ scope should get the employees for all organizations within the customer defined in the Token. This functionality however is not available for someone with a Token in the User scope. The same applies to a POST. Someone within the organization scope should only be allowed to add a new employee to his own organization. The functionality for the different scopes will usually only differ a little bit. In the case of getting the employees the difference is only a where on organization or otherwise on customer. In the case of a post their should be a check to see if for example the organization is part of the customer that is bound to the customer Token. **Current implementation:** Currently we have a base ApiController which is generic typed. The base controller calls an Query or CommandHandler with the entity type and all the implementation details are inside this handlers. _ApiController_               public abstract class ApiController<TEntity> : EntitySetController<TEntity, Guid>         where TEntity : class, IApiEntity     {         protected readonly IQueryProcessor QueryProcessor;         protected readonly ICommandProcessor CommandProcessor;              protected ApiController(IQueryProcessor queryProcessor, ICommandProcessor commandProcessor)         {             this.QueryProcessor = queryProcessor;             this.CommandProcessor = commandProcessor;         }              [HttpGet]               public override IQueryable<TEntity> Get()         {             var command = new GetEntityCommand<TEntity>();             return this.QueryProcessor.Process(command);         }     }      _EmployeeController_               public class EmployeeController : ApiController<Employee>     { }      _GetEmployeeHandler_               public class GetEmployeeCommandHandler : IQueryHandler<GetEntityCommand<Employee>, IQueryable<Employee>>     {         public IQueryable<Employee> Handle(GetEntityCommand<Employee> command)         {                  // Code that knows how to get a collection of employees.              // This collection contains all employees         }     }         _PostEmployeeHandler_               public class PostEmployeeCommandHandler : ICommandHandler<PostEntityCommand<Employee>, Employee>     {        public Employee Handle(PostEntityCommand<Employee> command)         {                  // Code that knows how to add an employee to the database.         }     }       **The question** Where and possibly how should I implement the scope based logic? I know there has to be a smart way to do this and a good place to implement this scope based logic, I just don't see it (yet).


title: Should I always start with UML as a good practice when designing classes?

text: I am in the middle of creating a Bundle for PHP application based on Symfony 2. I want the bundle to be clear and good designed, so I constantly move and refactor code, rename methods, reorder classes, move them to other folders, add some factories and adapters, proxies, and follow other oop design concepts. I'm thinking if I should design UML diagram first, then start to work with IDE. What is the best practice for designing good architecture? When I start with draw of UML class diagrams before, then after coding, even with empty methods and tests first, I stop following the diagram I drew before, because I found it not matching what I need. Can you share good practices for designing architecture for a libraries? I'm not talking about model (if so I could follow DDD).


title: How does one become proficient in a language and its idioms?

text: I'm a recent graduate and there are a few (three generally) languages I switch between based on the requirement. What I've found is I always have to look up syntax whenever I code. I know I'm not alone because Ryan Dahl, author of node.js, was not sure of JavaScript syntax during a demo. That's somewhat reliving to know. On the other hand, companies recruiting (at least FB because that's what they have told me for the upcoming interview) expect you to _quickly find the most effecient_ algorithm in your head first and then code it bug free. I don't know how much creative thinking one can do under pressure but for this question I'm concerned with the second part. So my question, > How does one before proficient learn "inside workings", idioms and in > general become proficient in a language? If the advice is language specific, I love Python the most so how does become a _Pythonista_? I want to be able to code without having to look up syntax, know and use idioms wherever apt, follow the standard practices, etc. ## Update Those who suggest practice, practice only makes permanent. Practice reinforces what you already know. So that may work for syntax, but you have other issues like internal workings, idioms, not-as-expected cases, etc.


title: Should we document stand-up meetings?

text: Another team in my company start to document their stand-up meetings, but I believe it is a waste of time. As far as I know, stand-up meetings are for communication not for status reporting (please, correct me if I am wrong) So, Should we document stand-up meetings?


title: User Authentication. Database lookup vs RPC call

text: If we have more than one service that uses same database - is it ok to move out user authentication on separate server and use RPC calls, instead of traditional database lookup?


title: What does the "4" in LCOM4 mean?

text: I know that methods in a class should have high cohesion which roughly translates to having all the methods use all the instance variables directly or indirectly. I know that _LCOM4_ (Lack of cohesion)metric is useful for having a quantitative figure of how much cohesive the methods in a class are. A class with a LCOM4 value of 1 will be considered pretty good while a class with LCOM4 value of, say, 10 is considered a poorly designed class and this probably tells that we are better off decomposing the original class into 10 separate classes. All this is okay but what does the _4_ signify in _LCOM4_ metrics?


title: Language design suggestion on database query

text: I am designing a new programming language. I am designing a syntax to implement queries. Currently this is how it works. **The database is accessible through entity object.** on this sample I have "entity.manufacturers" and "entity.products" table To get manufacturer with an ID of 1:                  var @manufacturer = entity.manufacturers where id = 1;      To query all products for @manufacturer:                   // Get all manufacturers products          var @products = entity.products under @manufacturer;         // No need to specify what links both since system already knows how entity is related      Currently I am using "under" as a keyword to get all records for @manufacturer. I want it to make sense by just reading the code. If you can give suggestions on a better syntax or keywords on how to implement this that will be awesome.


title: Redis strategy for activity log data

text: Our application requires an activity log of actions that a user has done. For example: 3/19/2013 \------------- 9:37 AM Chuck Norris scrapped 3 robots.   9:15 AM Chuck Norris fought 3 robots. Currently this is done with a gigantic query that compiles all of a user's activity on a given day. The query is so slow that that application literally forbids you from looking at more than a single day's activity at a time. These results could be aggressively cached in Redis. My question is: what is a good Redis key strategy for storing these activities? I need to be able do a lookup primarily based on the user ID and a date range. I've played with the following possibilities, but nothing has really leaped out at me as the optimal solution.               -- psuedo-code, obviously --     HMSET user:5345:activity date "3/19/2013" time "9:37 AM" action "Some action"     LPUSH user:5345:activity (json)     LPUSH user:5345:activity:2013:03:19 (json)      All three of these have significant tradeoffs. Assume a user hasn't logged in for four months - they might actually want to see their activity from four months ago at the top of the list. The second option gives me that, but there are trade-offs in that direction as well (like not being able to specifically query by date). Any thoughts on a better way to approach this?


title: Readability vs minimalism/compactness/conciseness in language design: are they antagonistic?

text: Currently, there is a discussion in the PHP-Internals mailing list regarding the implementation of a short syntax for arrays and objects, mainly `[1, 2, ...]` for standard arrays, `['one'=>1, 'two'=> 2, ...]` for associative arrays, and `{'one'=>1, 'two'=> 2, ...}` for objects and there is one general disagreement that bothers me: some people argue it is less readable. The main reasons I see this proposal was made is to augment simplicity and readability when using this fundamental data structure in PHP, but I'm having trouble processing the reason of why some people regard it as unreadable, you can even see that, readability is an item both in the pro and con list, and its both an argument for supporters and opposers. My suspicion is that opposers are just considering the standard case of `array(...)` vs `[...]`, but they are not seeing the nested case, meaning this:               $TV = array(         "flintstones" => (object)array(             "series"   => "flintstones",             "members"  => array(                 (object)array( "name" => "fred",    "role" => "lead", "age"  => 36, ),                 (object)array( "name" => "wilma",   "role" => "wife", "age"  => 31, ),                 (object)array( "name" => "pebbles", "role" => "kid",  "age"  =>  4, ),             ),         ),         "jetsons"     => (object)array(             "series"   => "jetsons",             "members"  => array(                 (object)array( "name" => "george",  "role" => "lead", "age"  => 41, ),                 (object)array( "name" => "jane",    "role" => "wife", "age"  => 39, ),                 (object)array( "name" => "elroy",   "role" => "kid",  "age"  =>  9, ),             ),          ),         "simpsons"    => (object)array(             "series"   => "simpsons",             "members"  => array(                 (object)array( "name" => "homer", "role" => "lead", "age"  => 34, ),                 (object)array( "name" => "marge", "role" => "wife", "age" => 37, ),                 (object)array( "name" => "bart",  "role" => "kid",  "age"  =>  11, ),             ),         ),     );      Would become this:               $TV = [         "flintstones" => {             "series"   => "flintstones",             "members"  => [                 { "name" => "fred",    "role" => "lead", "age"  => 36, },                 { "name" => "wilma",   "role" => "wife", "age"  => 31, },                 { "name" => "pebbles", "role" => "kid",  "age"  =>  4, },             ],         },         "jetsons"     => {             "series"   => "jetsons",             "members"  => [                 { "name" => "george",  "role" => "lead", "age"  => 41, },                 { "name" => "jane",    "role" => "wife", "age"  => 39, },                 { "name" => "elroy",   "role" => "kid",  "age"  =>  9, },             ],          },         "simpsons"    => {             "series"   => "simpsons",             "members"  => [                 { "name" => "homer", "role" => "lead", "age"  => 34, },                 { "name" => "marge", "role" => "wife", "age" => 37, },                 { "name" => "bart",  "role" => "kid",  "age"  =>  11, },             ],         },     ];      For me, the second case would be miles more readable, even refreshing since I can move my eyes quicker through it. There is a clear majority of people that want the short syntax, but I'm very interested in knowing why is the second example I provided less readable for some (being some of them well renowned devs, meaning they must have considered the nested case). Anyhow I've seen this argument other places, that minimalism is not the same as readability, but why for this specific case?, the short syntax is well known in other languages and nobody complains about readability, **_so why?_**. Thanks


title: Where should I handle fatal exceptions

text: Suppose I have a controller that loads a file and hands it over to the processing.   * Should I handle the exception in the file loader and return `Null` if something is wrong, or should I throw the exception and handle it in the controller?    * Without the file the rest of the program can´t work. Where should I handle a exception that shuts down the program properly? I want to shut down an Android application properly.


title: what should I save in local android DB to be more efficient and to last more than one session (and shouldn't be stored in the server only)?

text: I write an android app. The user sends the server its location and get places relevant to him. He then can up-vote or down-vote any offer. I wonder if I should write to local DB and when? I connect via fb only. As I see it, there is nothing i should save in local DB performance wize it's better to save and prosess anything at the server side. And also in a local memory (per application session). Any idea what should I save in local DB to be more efficient and to last more than one session (and shouldn't be stored in the server only) ?


title: Difference between Unified Process model and agile development

text: I am confused concerning the unified process model and agile development. When I'm reading about the UP, I'm only understanding that it is an iterative improvement. Can someone please clarify this?


title: What is the name of this relationship between objects?

text: Different types of dependencies have particular names, such as _linear dependency_ , _circular dependency_ , _self-referencing object_ , etc. What is the name of the dependency where those rules are true?   1. A has zero or more B,   2. B has zero or more C, and:   3. A has zero or more C. ![An UML diagram illustrating the relationship described above](http://i.stack.imgur.com/qjRPK.png) If there is no particular name for such relationship, do you have any suggestions?


title: Accepted best practices for setup.py of a forked project

text: ## Context: I was looking to see if there was a tool to do something (in my case I was looking for a proxy that would allow for http log inspection from a python test framework). There turned out to be a tool that would require only minor adjustment, and it seemed to be reasonably stable/mature, with no updates in the past 5 months (pymiproxy), so I forked the project (to here) and have got it working as I need. The goal behind the original project is simplicity, so I doubt a pull request would be accepted, especially since one of the files involved is only useful to my current employer. Finally I thought I should update the `setup.py` file, but I'm not sure - I have done a 'useful' amount of work on my fork, and while I have left the original files in tact, subclassing in my own modules, there is now significant additional functionality. I don't know that I feel comfortable claiming to be the 'author' of this module as it would be installed by python, but as the fork project author, I also don't feel comfortable leaving support emails directed to the original project's author. ## Question: What is the general accepted best practice for forked projects? Should the project be renamed to indicate that it is of a different purpose? The original project is not available through pip or else the structure of my project would allow that instead of forking, I only wrap the original as a dependancy. Should I in fact roll back my changes, put these in a new project, and get the two both listed in pypl, or is doing this on behalf of the original author going too far? ## Notes: Headings added to aid speed-reading. I'm looking for accepted best practices, so please no opinions without sources to back them up, be it an authoritative blog post, or examples of other projects which have done the same.


title: Data structure for accessing units of measure

text: TL;DR - I'm looking for the "optimal" data structure to define units within a unit of measure. * * * A `Unit of measure` is essentially a `value` (or quantity) associated with a `unit`. SI Units have seven bases or dimensions. Namely: length, mass, time, electric current, temperature, amount of substance (moles), and luminous intensity. This would be straightforward enough, but there are a number of derived units as well as rates that we frequently use. An example combined unit would be the Newton: `kg * m / s^2` and an example rate would be `tons / hr`. We have an application that relies heavily upon implied units. We'll embed the units within the variable or column name. But this creates problems when we need to specify a unit of measure with different units. Yes, we can convert the values at input and display but this generates a lot of overhead code that we'd like to encapsulate within its own class. There are a number of solutions out on codeplex and other collaborative environments. The licensing for the projects is agreeable but the project itself usually ends up being too lightweight or too heavy. We're chasing our own unicorn of "just right." Ideally, I could define a new unit of measure using something like this: > UOM myUom1 = new UOM(10, volts);   >  UOM myUom2 = new UOM(43.2, Newtons); Of course, we use a mix of Imperial and SI units based upon our clients' needs. We also need to keep this structure of units synchronized with a future database table so we can provide the same degree of consistency within our data too. * * * What's the best way of defining the units, derived units, and rates that we need to use to create our unit of measure class? I could see using one or more enums, but that could be frustrating for other developers. A single enum would be huge with 200+ entries whereas multiple enums could be confusing based upon SI vs Imperial units and additional breakdown based upon categorization of the unit itself. Enum examples showing some of my concerns: > myUnits.Volt   >  myUnits.Newton   >  myUnits.meter > > SIUnit.meter   >  ImpUnit.foot DrvdUnit.Newton   >  DrvdUnitSI.Newton   >  DrvdUnitImp.FtLbs Our set of units in use is pretty well defined and it's a finite space. We do need the ability to expand and add new derived units or rates when we have client demand for them. The project is in C# although I think the broader design aspects are applicable to multiple languages. * * * Update 1: One of the libraries I looked at allows for free-form input of units via string. Their UOM class then parsed the string and slotted things accordingly. The challenge with this approach is that it forces the developer to think and remember what the correct string formats are. And I run the risk of a runtime error / exception if we don't add additional checks within the code to validate the strings being passed in the constructor. Another library essentially created too many classes that the developer would have to work with. Along with an equivalent UOM it provided a `DerivedUnit` and `RateUnit` and so on. Essentially, the code was overly complex for the problems we're solving. That library would essentially allow any:any combinations (which is legitimate in the units world) but we're happy to scope our issue (simplify our code) by not allowing every possible combination. Other libraries were ridiculously simple and hadn't even considered operator overloading for example. In addition, I'm not as worried about attempts at incorrect conversions (for example: volts to meters). Devs are the only ones who will access at this level at this point and we don't necessarily need to protect against those types of mistakes.


title: Time consuming Unit test for support for 100,000 records: Am I doing it right?

text: I am working on adding test coverage for an application that previously didn't have any. One additional requirement that emerged is that one of the background processes should be able to process 100,000 rows at a time. I've written a unit test that ensures that the background process is able to work with the 100,000 entities without crashing the interpretter (PHP) on a 4.0MB memory limit. But each test run takes close to 4 minutes to finish. All other tests take just 10 seconds to run. Can this be approached differently than a unit test?


title: Keeping agile with zero-bug/defect policy

text: In our project we work in a zero-bug (a.k.a zero-defect) methodology. The basic idea is that bugs are always higher in priority than features. If you're working on a story and it has a bug it must be resolved in order for the story to get accepted. If a bug is found during the sprint for an older story we need to put it next on our backlog and resolve it - top priority. The reason I'm saying resolve is that we not always fix the bug. Sometime we just declare it "won't fix" as it's not that important. All-in-all it sounds great. We're shipping high-quality products and don't carry "a hump" in the form of a huge bug backlog. But i'm not sure this approach is correct. I do tend to agree that we always need to fix serious bugs ASAP and we need to throw-away non-interesting bugs. But what about bugs that are important but not as important as new features? I tend to think they should be filed in the backlog with a suitable priority. I'll give an example in order for it to be clearer - in my project we work with a UI written in flex. We have a wizard screen that opens at the same size for every screen resolution. It turns out that when we extend the wizard window, one of the pages does not look good (there is a vertical scroll bar that does not disappear although the wizard can now present everything and does not require the scrollbar). I think this bug is ugly. I'm sure it MUST be fixed. But we're on a tight schedule and we have a lot of features that we're afraid won't make the cut and enter the release. I feel that we can live with such bug. It does need to be fixed but on lower priority than other features (so, in case we won't be able to complete it, at least we didn't leave out more important features). But, we work in a 0-bug policy and it must be fixed now (even though we spent more than a day trying to resolve it and we'll need at lease another one). I would love to hear opinions about how to manage with bugs that I don't want to mark as "won't fix" but also are not of highest importance.