Why is a private member accessible in a static method?

The following is pseudo code, I tried it in Java and PHP and both worked:               class Test {               private int a = 5;              public static function do_test(){             var t = new Test();             t.a = 1;             print t.a // 1         }          }          Test::do_test();      Why can you do this in OOP paradigm and what's the use of it?


What does " (int) value & 0x1, (int) value & 0x2, (int) value & 0x4, (int) value & 0x8 means"

> ![code](http://i.stack.imgur.com/KSwRO.jpg) The "value" ranges from 0 to 15 (it's possible values). When will those 4 "if"condition be met? If my (int)value = 2 does this mean 0010?                           if  ((int)value & 0x1)                  {                     //statement here                 }                 if  ((int)value & 0x2)                  {                     //statement here                 }                 if  ((int)value & 0x4)                  {                     //statement here                 }                 if  ((int)value & 0x8)                  {                     //statement here                 }


Consistent header HTML across multiple sites

We've got several sites. Some are HTML/Angular, some are built on a CMS, some are built on other code. What we'd like to do is have a consistent header experience for each site. I'm trying to figure out the best way to do this. I've got a couple of options -   1. Have it served on one site - then put it in an iFrame on each of the sites.      * Advantages here are that we only need to deploy to one place, it'll be always consistent     * Downsides I can see are that it may not work that well when we have to resize the header responsively, and that I'm not sure if using iframes are considered bad practice now. Also I'm not sure how the links would work with angular routing.   2. Have the HTML/CSS stored in my source control, then have each application pull it in.     * Advantage/Disadvantage - headers aren't automatically updated across all sites. They have to be deployed individually.     * Disadvantage - Possible CSS conflicts since its written in isolation?     * Advantage - Pretty simple solution   3. Some other way?


Uniqueness of for loop

How does the for loop function is implemented so that it can accept `;` as parameter separator rather than `,` which is trivial in normal functions.


How do I add link-time optimization capabilities to my LLVM-based compiler?

I am designing and implementing a programming language, and I am using LLVM for native code generation. Among others, performance is a key feature of the language, and as such, I am looking to implementing link-time optimization. On the official LLVM site, I've read that > LLVM features powerful intermodular optimizations which can be used at link > time. However, the page in question does not mention how a user can request link- time optimization. In particular, it only explains the theory (and some big- picture decisions of implementation) of LTO, but it does not reference any API documentation nor a tutorial. I have performed a quick search on Clang's code base, but the results aren't too informative or relevant either – I haven't even found what settings the `-flto` switch turns on in Clang, let alone the changes in code generation that make it possible for the linker to optimize across object files. Now, I suppose doing LTO should go along the lines of:   1. Generating some sort of metadata in the object/bitcode file so that the linker knows it can employ LTO. Maybe this needs to contain concrete information about the module, the functions to be optimized, etc. (I really have no idea what exactly should go in there...)   2. Then adjusting my code generation procedure (i. e. the way I am using the LLVM API) in a manner that it "supports" LTO. After some researching on the internet, I've found this related LLVM source file, so I assume it's possible to automatize at least part of this task, but – as always – the autogen'd LLVM documentation is scarce at best. So, my question is: is my description of the process of incorporating the LTO features of LLVM in my compiler correct, and if so, can you suggest me any sort of documentation or tutorial which I could base my project on?


Single python file distribution: module or package?

Suppose I have a useful python function or class (or whatever) called `useful_thing` which exists in a single file. There are essentialy two ways to organize the source tree. The first way uses a single module:               - setup.py     - README.rst     - ...etc...     - foo.py      where `useful_thing` is defined in `foo.py`. The second strategy is to make a package:               - setup.py     - README.rst     - ...etc...     - foo     |-module.py     |-__init__.py      where `useful_thing` is defined in `module.py`. In the package case `__init__.py` would look like this               from foo.module import useful_thing      so that in both cases you can do `from foo import useful_thing`. **Question:** Which way is preferred, and why? EDIT: Since user gnat says this question is poorly formed, I'll add that the official python packaging tutorial does not seem to comment on which of the methods described above is the preferred one. I am explicitly _not_ giving my personal list of pros and cons because I'm interested in whether there is a community preferred method, not generating a discussion of pros/cons :)


How achieve a page-change proof player?

I am interested in develloping a web music player similar to the soundcloud one However, I can't figure out one thing: How player like soundclou one (and some other one) can "resist" a page change, continue playing without any latency, even if the page in the background is loading, the player is here and continue his job without any lag at the momment we click links. The only way to stop it is to reload the page with the browser How can this be achieved? Does this used using a particular language and site architecture that center the player? If not, does any language / framework offers possibility to do thing like that? EDIT: So I made a Few search, and I get the following Idea:   * Pjax : That allow you to reload only certain content.   * HTML5 History API : The API Behind PJax   * One-page APP : Much harder. But using Ajax it could work. Are these solution good? Wich one would be easier/ Better? Are there other alternative?


Quite confused about what constitutes Current state of a resource

From REST in Practice: Hypermedia and Systems Architecture: > The current state of a resource is a combination of: > >   * The values of information items belonging to that resource >   * Links to related resources >   * Links that represent a transition to a possible future state of the > current resource >   * The results of evaluating any business rules that relate the resource to > other local resources > a) why would " _links to related resources_ " also represent the current state of a resource? b) I also don't quite understand why " _Links that represent a transition to a possible future state of the current resource_ " also represent the the current state. Namely, those links represent the possibility, not the current state. Analogy would be an int variable set to value 10. It's possible that in the future this variable will get processed and set to value 100, but we don't claim its current state also includes possible future state of 100?! **REPLY:** **1)** > links to related resources: imagine a "chat_room" resource. The links to > people in that room will change as they come and go. In other words, a > resource's relationships to other resources may change. **a)** I also began learning domain driven design and there an entity **E** may have _child entities_ ( thus **E** is a parent in a relationship ) and **E's** relationship with its _child entities_ may change ( ie some _child entities_ may be assigned to different parent or may get deleted). But even though **E** has _one-to-many relationship_ with its _child entities_ , we don't consider that relationship as also representing _the current state of E_. That's is why I'm puzzled as to why in REST the **links to related resources** also represent the _current state_?! **b)** > imagine a university has a "student" resource. There might be a link to > "register" in a class, a link to "apply for housing", and links to "tune > in", "turn on" and "drop out". Each link may change the state of the object, > or may yield appropriate information for the resource state. For example, > the correct Student Housing application for that student. It sort of makes sense that the _state of current resource_ also constitute **those links to related resources** , which may state change _the state of the current resource_. But it doesn't make sense that **the state of the current resource** also constitute **links to those related resources** which don't change the _state of the current resource_?! **2)** > But the resource may be a sort of state machine. So a "car" resource might > have links to "start_engine" if it's stopped. It might links to "speed_up", > "slow_down", and if the speed is slow enough, "stop_engine". In other words, > links to transition to other valid states based on the current state. **a)** > links to transition to other valid states based on the current state. I assume you've made a typo and what you meant to write is " _links to transition to other valid states **is** based on the current state_"? **b)** So could we say the reason why **links that represent transitions to other states** also represent _current state of a resource_ is because _every resource with such links_ could be considered a _state machine_ , and with _state machine_ , _links to other valid states_ do represent _current state_ ( I hope my ramblings make some sense )?! **2\. REPLY:** **1)** > But it seems more natural in handling structured data to just bundle the > "chat_room" and "chat_room_person" information together. I assume technically, _related resources themselves_ don't represent the _current state of a resource_. Instead, only _links to these related resources_ represent _the current state of a resource_?! **2)** > In REST, the goal is to eliminate all out-of-band communication. So we > supplement the state (ON) with links that represent all the valid > transitions for that state. So we want to avoid more documentation. The > resource representation can tell us, "This is where I am, and this is where > I can go next." In REST the **links that represent transitions to other states** also represent _the current state of a resource_ , but could we argue that logically ( thus not in the context of REST ) these links don't really _represent the current state of a resource_ , and thus only reason why in REST they do represent _the current state of a resource_ is because REST is build around that assumption ( or is at least more efficient that way )? thank you


What properties does an object oriented language have?

I'm currently working on a game and wanted to add some scripting support. Due to trying to keep the entire codebase in managed c# (Excluding Monogame), I am using a custom language for the scripting (No managed only implementations of Lua exist...except AluminumLua which is incomplete). In such a language, basic provisions would need to exist. These would include:   * Objects / Properties / Variables   * floats and strings   * Functions   * Conditionals   * Loops Am I missing any major parts of a basic object oriented language? **EDIT:** As comments have pointed out, I would be far better finishing the incomplete implementation of Lua for C# rather than designing my own language...which is what I am going to do. However, I am still curious what the properties of an object oriented language are. **So, what properties does an OO language have?** Some definitions of object orientation (again, decided in the comments): Combining the state of an object with it's behavior. An object oriented language is is a method of combining the state of an object (it's properties) with behavior (functions). Object orientation is defining data (like a C struct) and providing specific methods to interact with it (the function ChangeValue), rather than give the person using that code the ability to change any part, including 'internal' components. Object orientation is just a way to sort the data (that will be represented in binary) more clearly to a programmer and protecting against incorrect use (e.g. setting a char instead of a byte into a function).


Apache Wicket, updating data without using a form, is it safe?

I have a ListUser.java class with a datatable, displaying UserData information, displays 4 columns, the last column is an AbstractColumn that has on it's populateItm method has added a inner class LinkedPanel that fills the column with buttons, one of these buttons is an Link,Model... this link has a @Override onClick() method, that calls a Injected userDataDAO, using the Model, I obtain the UserData object, I update this object and pass it directly to the userDataDAO and merge the object into database, without using any form, is updating directlly safe? (or a good practice) * * *               ListUsers.java is a List that has a LinkPanel that displays buttons on the last column of the          List<IColumn<UserData, String>> cols = new ArrayList<>(4);         cols.add(new PropertyColumn<UserData, String>(new Model<>("Usuario"),"username"));         cols.add(new PropertyColumn<UserData, String>(new Model<>("Creacion"),"dateCreation"));         cols.add(new PropertyColumn<UserData, String>(new Model<>("Ultimo Ingreso"),"lastLogin"));     cols.add(new AbstractColumn<UserData, String>(new Model<>("Operación"), "Desactivar") {                  @Override             public void populateItem(final Item<ICellPopulator<UserData>> item, String string, final IModel<UserData> imodel) {     item.add( new LinkPanel(string, imodel, "deshabilitar")                 );             }         });      * * *               ListUsers.html     ...

     ...      * * *               public class LinkPanel extends Panel {              public LinkPanel(String id, final IModel<UserData> imodel, String label) {             super(id, imodel);             add(                     //Boton habilitar/deshabilitar                     new Link<UserData>("deshabilitar", imodel) {                         @Override                         public void onClick() {                                  usData.setEnabled(!usData.isEnabled());                             userDAO.edit(usData);                             imodel.setObject(usData);                             getSession().info(Msg.OPERATION_SUCCESSFUL);                         }     ...


How to minimize typos when you code?

I make a lot of typing mistakes when I program. I have a good keyboard writing speed but I try to write faster and in the process end up making typos. I want to type faster, but make less errors. Can I do something to improve the situation?


Any OOP design pattern that is somewhat representative of all of the SOLID OOP design principles at play?

I'm trying to teach an object oriented design principles course (on SOLID) at a training institute. I also want to teach the students a few OOP design patterns such as factory, singleton and one other. I know there is no 1 to 1 match between SOLID principles and OOP Design patterns, but I want to introduce the students a pattern that is sort of inclusive of all the SOLID design principles at play. Any ideas? I'm really trying to fit in the observer pattern but want to keep it conforming with all the SOLID principles.


Should I store x,y coordinates as an array, a class object, or two variables?

I have a `MyObject` which has an x and y coordinate. as far as I can see, I can store it in three ways:               class MyObject:         def __init__(self, x, y):             self.x = x             self.y = y          class MyObject:         def __init__(self, x, y):             self.position = [x, y]          class MyObject:         def __init__(self, x, y):             self.position = Coord(x,y) #Coord class created elsewhere      Is there a best practise either way for this ? Where I'm thinking this is relevant, is when passing these coordinates into other methods: eg.               myObj = MyObject(0,0)     searchLocation(myObj.x, myObj.y)     searchLocation2(myObj.position)


What are the benefits of using entity framework code-first instead of designing my database using SQL?

I'm currently working on designing a small web application (MVC5) and I'm to the point of designing my database. I have the schema I want worked out and I am quite proficient in SQL Server. (I have my SQL 2012 MCSA.) I'm going to be using entity framework 6 as my ORM. I've been quite interested in the code- first approach because I'm not a big fan of designers and I like to be able to see and work with the code myself. Because my SQL skills are quite strong I am inclined to create the schema myself and write my own `CREATE TABLE` queries, etc. I feel like that gives me a lot more control over constraint and index creation. But I haven't really worked much with entity framework in the past so there may be some benefits to this that I'm missing. I know you can do code-first against an existing database in EF6 anyway, so that would be another option. I've tried googling around a bit and reading MSDN but most of the benefits seems to be that you don't need to worry about the SQL. Since that isn't a concern of mine I'm failing to see the benefit of allowing entity framework to create my schema. Are there any benefits to allowing entity framework to create my database that I'm missing?


Should an object query its owner?

I have a `World`               class World:         def __init__(self):             self.size = 10             self.n_busStops = 10                  self.busStopMatrix = SpatialGraph(self.size, self.n_busStops, 1.0)             self.buses = [Bus([0,1,2,3,4,5,6,7,8,9])]      Now each of the buses are going to move around the world, dropping off and picking up passengers. The bus contains information about its route. When it gets to its next stop, it needs to query the `busStopMatrix` to find out how many passengers there are there, and how far away the next stop on its route is. Is it a good idea for an object to query its parent like this? If so, what is this design pattern called? Something like:               class World:         def __init__(self):             self.size = 10             self.n_busStops = 10                  self.busStopMatrix = SpatialGraph(self.size, self.n_busStops, 1.0)             self.buses = [Bus([0,1,2,3,4,5,6,7,8,9], owner =self)]          class Bus:         def __init__(self, route, parent):             self.route = route             self.currentStop = route[0]             self.parent = parent         def move(self):              ifAtDestination():                 pickUpPassengers(self.parent.getPassengersAtStop(currentStop))      I otherwise can't think how the `Bus` can get information about the world it is in. The alternative I can think of is that the route is made up of references directly to the BusStops, so it can directly query them. eg.               class World:         def __init__(self):             self.size = 10             self.n_busStops = 10                  self.busStopMatrix = SpatialGraph(self.size, self.n_busStops, 1.0)             self.buses = [Bus([busStopmatrix.getAllStops()])]          class Bus:         def __init__(self, route):             self.route = route             self.currentStop = route[0]              def move(self):              ifAtDestination():                 pickUpPassengers(currentBusStop)


In layman's terms, what is left recursion?

According to one page on code.google.com, "left recursion" is defined as follows: > Left recursion just refers to any recursive nonterminal that, when it > produces a sentential form containing itself, that new copy of itself > appears on the left of the production rule. Wikipedia offers two different definitions: >   1. In terms of context-free grammar, a non-terminal r is left-recursive if > the left-most symbol in any of r’s productions (‘alternatives’) either > immediately (direct/immediate left-recursive) or through some other non- > terminal definitions (indirect/hidden left-recursive) rewrites to r again. > >   2. "A grammar is left-recursive if we can find some non-terminal A which > will eventually derive a sentential form with itself as the left-symbol." > > I'm just barely starting out with language creation here, and I'm doing it in my spare time. However when it comes down to selecting a language parser, whether left recursion is supported by this parser or that parser is an issue that _immediately_ comes up front and center. Looking up terms like "sentential form" only leads to further lists of jargon, but the distinction of "left" recursion almost has to be something very simple. Translation please?


How should I create lo-fi (non-interactive) UI prototypes?

I'm currently working on throwing together some basic prototypes, partly to gather requirements and partly to design the final UI. At the moment I'm trying building up the screen using Post-it notes, with yellow notes for information and pink for actions (buttons or menus). The idea being that you can easily move, remove and add information. But I'm sure there are more efficient methods out there. What is the recommended way for developers to efficiently create non- interactive UI prototypes? And why? * * * I tried some pen, paper and Post-it note versions and they went down like a lead balloon (likely my drawing skills). In the end I used Balsamiq, which thus far is liked by most users and they get it is prototype. Alas, some people are still having problems with the idea that first one should get an idea of what the application should do via some lo-fi prototypes and really want to "see something on the screen" before committing to anything.


Is it acceptable for child classes to "break" parent class functionality?

One of the devs that works with me is following the Open/Closed Principle to add functionality to a Model by extending from our framework ORM.               class BaseModel extends ORM {        ...     }      All our models are now inheriting `BaseModel`, and this model works well in the context of our application.               class Product extends BaseModel {       ...     }      The problem comes when we tried to use the models as if they where extending directly from the ORM, use some of the most basic functionality:               $product = Product::factory();     $product->name = 'foo';     $product->price = 9.99;     $product->save();      This code should have worked well but it failed because now the factory method requires a list of parameters. I think that as long as the models works well within the context of our product we are good; but I also have mixed feelings about not supporting some of the basic core functionality of the parent class. Thoughts?


Java Desktop Application For Network users

I'm developing a desktop application using Java. My application will run in a network environment where multiple users will access the same database through the application. There will be basic CRUD opreations (Insert, Update, Delete, & select), which means there will be chances of deadlock, or two users trying to update the same record at same time. I'm using the following   * Java Swing for Clients (MVC).   * MySQL Server for database (InnODB).   * Java Web start. Now, MySQL is centralized on the network, and all of the clients connect to it. The Application for ERP Purpose. I searched the internet to find a very good solution to ensure data integrity & to make sure that when updating one record from one client, other clients are aware of it. I read about Socket-server-client & RESTful web services. I don't want to go web application & don't want to use any extra libraries. So how can I handle this scenario: If User A updates a record:   1. Is there a way to update User B's screen with the new value?   2. If user A starts updating a record, how can I prevent other users from attempting to update the same record?


Dependency injection: At what point am I allowed to create a new object?

I am refactoring a PHP application, and I am trying to do has much dependency injection (DI) as possible. I feel like I've got a good grasp of how it works, and I can certainly see my classes becoming a lot leaner and more robust. I'm refactoring so that I can inject a dependency rather than create a new object within the class, but at some point I am going to have to create some objects, that is, use the dreaded `new` keyword. The problem I have now run into is at what point can I actually create new objects? It's looking like I'll end up at a top level class, creating loads of new objects as there is no where else to go. This feels wrong. I've read some blogs that use factory classes to create all the objects, and then you inject the factory into other classes. You can then call the factory methods, and the factory creates the new object for you. My concern with doing this is now my factory classes are going to be a `new` free-for-all! I guess this may be OK as they are factory classes, but are there some rules to stick to when using a factory pattern and DI, or am I going way off the mark here?


Cascading deletes from an aggregate root through out the entire aggregate doesn't make sense

Based on the same example for this question. Within the Pro ASP.Net MVC 4 by Adam Freeman, there is a discussion on aggregates and aggregate roots with a simple auction system. There are members who bid, items that are bidded upon, and bids. The author says that there would be an aggregate of Item and Bid with Item being the aggregate root. The author then mentions that aggregates roots can be used to do a cascading delete, which for this example means that if an item is deleted, all bids on the items are deleted. This makes sense. The problem is, bids only belong to the item/bid aggregate, and not to a member/bid aggregate. If I delete a member of the system who places bids, it would seem reasonable that all their bids are deleted as well. Yet, I can't do that without 'break' the aggregate. I also can't simply get a members list of bids. My level of confusion, given how simple the example is, makes me a bit worried. Is this just a bad example, could member/bid be a valid aggregate instead and there is some level of arbitrariness in making the choice of your aggregates that is acceptable as long as you make a choice, is there some way to have models belong to multiple aggregates, or am I just missing something? P.S. The answer in the question I linked says that domain driven development is just very tricky, but it doesn't go into enough details as to how it is tricky and why the trickiness induces confusion and as such my questions about it still remains.


Code testing practice

So now I have come to the conclusion like many others that having some way of constantly testing your code is good practice since it enables fewer people to be involved (colleges and customers alike) by simply knowing what's wrong before someone else finds out the hard way. I've heard and read some about Unit Testing and understand what it's supposed to do and all. The there are so many different types of bugs. It can be everything from web browser not being able not being able to send correct values, javascript failing, a global function messing up a piece of code somewhere to a change that looked good when testing it out but fails in some special case which was hard to anticipate. My simply finding these errors I learn to rarely repeat them again, but there seems to always be new bugs to be found and learnt from. * * * I would guess maybe the best practice would be to run _every_ page and it's functions a couple of times, witness the result and repeat this in Firefox, Chrome and Internet Explorer (and all smartphones apparently) to make sure it works as intended. However this would take quite some time to do consider I don't work with patches/versions and do little fixes here and there a couple of times per week. What I prefer would be some kind of page I can just load that tests as much things as possible to make sure the site works as intended. Basicly just run a lot of cURL's with POST-values and see if I get expected result. But how would I preferably not increase the IDs of every mysql rows if I delete these testing rows? It feels silly to be on ID 1000 with maybe 50 rows in total. If I could build a new project from scratch I would probably implement some kind of smooth way to return a "TRUE" on testing instead of the actual page. But this solution would for the moment being have to be passed on existing projects. * * * **My question**   What would you recommend to be the best way to test my site to make sure that existing functions does their job upon editing the code? Should I consider to implement a lot of edits first, then test manually the entire code to make sure it still works? Is there any nice way of testing codes without "hurting" the ID columns? **Extra thoughs**   Would it be a good idea to associate all of my files to the different parts of my site which they affect? For instance if I edit `home.php` I will through documentation test if my homepage's start works as intended since it's the only part of my site it should affect.


Why are side-effects considered evil in functional programming?

I feel that side effects are a natural phenomenon. But it is something like taboo in functional languages. What are the reasons? Edit: My question is specific to functional programming style. Not all programming languages/paradigms.


Helper Methods Placement

Here's a question that's always bugged me. I'm going to use java as an example because I've almost never run into a problem in java where I didn't need to use helper methods in its class structure. Let's say I have a method that does a thing or two and then calls a helper method:               public void doStuff() {         int x = 4;         int y = 5;         doStuffHelper(x, y);     }      Now I need to create a private method, `doStuffHelper`, that doStuff calls with x and y. For readability I always put the helper directly above or below the function, but I can never quite decide which one is better. What are your thoughts/experiences with it? I know the question seems trivial, but since I don't have any guiding principles on it, I find that it always kills coding time deciding what to do and re-organizing my code if it doesn't work out. If there is no consensus, I think it's time to finally commit to one over the other for me.


How to reduce errors in dynamic language such as python, and improve my code quality

I post the origin question in stackoverflow, some people suggest me to post here I've always have trouble with dynamic language like Python. Several problems:   1. Typo error, I can use pylint to reduce some of these errors. But there's still some errors that pylint can not figure out.   2. Object type error, I often forgot what type of the parameter is, int? str? some object? Also, forgot the type of some object in my code. Unit test might help me sometimes, but I'm not always have enough time to do UT. When I need a script to do a small job, the line of code are 100 - 200 lines, not big, but I don't have time to do the unit test, because I need to use the script as soon as possible. So, many errors appear. So, any idea on how to reduce the number of these problems?


Commenting regular expressions

Are there any common practises for commenting the regular expressions: inline comments referring different part of RegEx or general comment for all expression?


C# Dynamic types

I just read a chapter in a programming book about Dynamic types. Although they are quite neat I cant think of a single real world example where I would use them. Does anyone here actually use them and for what?


How can I motivate myself to start learning more?

I've been interested in programming for a while now, and have been slowly, slowly, slowly working on things over the years. However, I don't feel like I've learned much. I've only really stuck with familiar languages (Java, C# and I've tried a little bit of PHP). The problem is that in those languages, I've only brushed upon the surface of them and have restricted myself to doing fairly simple things. For example, as a Java project, I've downloaded the source code for some game and changed a few things to my liking, but nothing terribly difficult. In C#, I've made a few WinForm and console projects to do some repetitious or routine tasks for me, which is nice, but again nothing too complicated. I've just barely begun to grasp the concept of classes, multithreading and some basic but essential tools that are required in modern object-oriented programming. ("Why can't I just shove everything into one monster-sized class?" "Why can't I just run everything in one thread?" are questions I used to wonder about) I've never made a large project by myself. Ultimately, my kind of "dream" hobby project is that I would like to create a game using DirectX technology. I say that because I've used XNA but it requires the user to install a framework to get it running, and I also feel that if I use the framework, that a lot of the back-end work is being obscured from me. (DirectX or OpenGL seem to be about as close to the machine as I can get without going overboard in complexity. DirectX is also installed on most [if not all] Windows machines that plan on running games.) But I haven't even begun to even think about starting that. The amount of things I need to know to undertake a task is absolutely overwhelming. I wouldn't know where to begin. Likewise, I also feel inadequate because I've restricted myself to [what I see as] easy languages. I feel like I should start learning some scripting language or learn this or learn that, which is quite daunting. \-- **tl;dr** : I've been slowly teaching myself to program for a while now, but have been restricting my knowledge to limited languages and only scratching the surface of what I can do. I want to learn more and possibly start a decent-sized project (I can only make so many text-based RPGs and calculators), but the massive amount of knowledge I'll need is very intimidating. One of my concerns is that I know so little about programming languages in general. Is it better to learn several languages or to be able to delve deep into one single language? How can I motivate myself to learn more? Am I thinking about this the wrong way?


Why is using System.out.println() so bad?

Of course, it is very good use to use a logging framework for the error messages or warnings. But sometimes I use System.out.println() if I want to try something new in a short time. Is it really so bad using System.out.println() for some quick test?


Should I list a website I created as experience on my resume?

I'm a recent graduate with a degree in computer science and I was wondering if I should list a website I created as experience on my resume. The website wasn't technical in nature, mainly just demotivational posters and comedic lists of things. It did, however, garner 2,000 - 4,000 page views a day on average. _**Positives_**   * I personally wrote HTML/CSS/JavaScript for parts of the site   * I acquired some skills involving analytics and advertising, as well as how to reach an audience via social media _**Negatives_**   * General quality and type of content on the site I should probably mention that the site no longer exists. The Wayback Machine is the only way an employer could actually see the site. As far as content goes, I was a bit vague. The best comparison I can come up with is that it had content that would be along the same lines as what Cracked.com has now.


Why is Flags Enumeration considered an intermediate skill?

I was reading this article: Designing Flags Enumerations @ msdn and it says > Combining flags enumeration values is an intermediate skill that should not > be required for developers implementing common scenarios. I think flags enumeration is awesome - something I learned about during my experience with C. Why does it seem like this article is cautioning developers away from what I consider to be a useful (and not complex) skill?


When to confront a good project leader or boss

Our project head is a genius software architect, a gentle and considerate person in general, a geek by nature and delicate by voice. But, at times, we (my teammates and I) differ in opinions -- especially of software architecture issues, system design issues, UI issues, etc., with our leader. When and how (if ever) should we express the difference in opinions?


Business rules, business logic, input validation

This might be asked a thousand times but couldn't find the answer. I just wonder how you people handle the business logic errors? Im trying to do a nice api for my business model. Some methods have quite a lot of validation and I just wonder how should I report them if something goes wrong? Returning true or false or null sometimes won't say what was the actual cause. Sometimes it works sometimes it is not enough. I read that some people use exceptions. I've thought that I could return error messages and when everything goes fine then it would be null. Somehow error codes just don't add up for me..


Using a DSN database connection is a bad practice?

During all my professional lifetime that I have been programming in Windows enviroments, I advised my friends and coworkers to not use a DSN database connection in their applications, based on my own personal conclusions, but I really haven't seen any evidence of them. I know that using a DSN connection via ODBC data source, implies that this connection will use an ODBC driver. I know by some documentation that ODBC is an language-agnostic, OS-agnotic API to connect to databases, everything that carries this level of flexibility comes with some downpoints (could be possible that some specific functionability can't be used with ODBC) or could be that the performance could be lower than using a more direct API (OLEDB or other). I know that using a DSN-less connection has some problems by itself like securely storing the access information to the database server/file ( can be solved with some kind of encrypter on the data), or unexpected changes in the name of provider used in the connection drivers (Specific case of old informix drivers). Is this correct, or I'm missunderstanding something?


Fastest way to open a file in Visual Studio knowing only its name

What is the best/fastest way to open a file in Visual Studio knowing only its name? In Eclipse there is "Open Resource" which allows you to interactively search for all files in the workspace, but I cannot find a similar good function in Visual Studio. The normal "open file" function in Visual Studio opens the Windows file dialog, which is pretty useless since I have to know exactly where the file is.


What does it mean that file IO binary flag is only relevant on Windows

I was reading a question and one of the comments mentioned that "The binary flag is only relevant on Windows". Given the context of the question and answer, I interpret this statement as `on non-windows machines, we don't need to specify text or binary mode when doing file IO` The context of the question is to read all bytes of a file into a string (presumably preserving bytes). It seems very relevant to me whether I'm reading the data as text or bytes, since reading text involves dealing with encoding. If I'm reading a UTF-16 file, for example, what I get in text mode is much different from what I get in binary mode. Assuming my interpretation of the statement is correct, is it unnecessary to specify whether a file should be opened in text or binary mode on non-windows machines? That is, all files are read in binary mode by default. Otherwise, what could the statement be referring to? (the comment received a number of upvotes so presumably this is not just one person's opinion)


What is a good method of storing test data for development and unit testing with angular and jasmine?

What is a good method of storing JSON data/objects for development and unit testing with angular and jasmine? I have seen some ways of accomplishing this. However, since I am new to unit testing with JavaScript, I fear going in a bad direction. Here are some examples of what I'd like to accomplish:   * Let's say I want to develop my site off a set of test data and and then later on plug it into a database. I figure it would be easier if I am developing and testing off of the same data to start. Maybe all I have to do is reference a js file which has a method in it for returning an array of that data. I don't know what setbacks that might have.    * Another example would be that my initial reaction when trying to make a test that uses data was to simply make a $http call to my .json file. I quickly learned I can't do that and would have to mock the data. It seems a pain to have my data both in a unit-test mock as well as a .json file when the current purpose of the data is just for test/dev. I'll have to manage it in two places.


How should a director conduct an interview for a programmer / software engineer position?

I always wonder when conducting an interview why a director or VP of Engineering is involved? If a team of engineers and hiring manager want to hire a person, I don't ever see a director or VP would veto, unless the candidate said something egregious. Is this just to make the candidate feel they are valued? What's the rationale?


How to turn on/off code modules?

I am trying to run multiple sites using single code base and code base consist of the following module (i.e. classes)   * User module    * Q & A module    * Faq module and each class works on MVC pattern i.e. it consist of   * Entity class    * Helper class (i.e. static class)    * View (i.e. pages and controls) and let's say I have 2 sites site1.com and site2.com. And I am trying to achieve following functionality   * site1.com can have User, Q & A and Faq module up and running   * site2.com can have User and Q & A module live while Faq module is switched off but it can be turned-on if needed, so my query here is what is the best way to achieve such functionality Do I introduce a flag bit that I check on every page and control belonging to that module? It's more like CMS where you can turn on/off different features. I am trying to get my head around it, please provide me with an example or point out if I am taking the wrong approach.


Why is $ in identifier names for so many languages?

A lot of scripting languages like Perl, Awk, Bash, PHP, etc. use a $ sign before identifier names. I've tried to look up why but never had a satisfactory answer.


Dev vs Stage environment vs Prod Environment

I work for a company where we build enterprise applications, and we maintain three environments: dev, stage and prod. The meaning of dev is intuitive: it's the environment used during development of the application. What's the difference between stage and production environments?


Should one learn new languages or only should concentrate on languages you already know and increase your knowledge of it?

Which way is more beneficial and productive?


Database of words and related words for search engine

I need to be able to search for a word in the English language and have a list of related words be displayed. Let's say I have a list of 100 words that the user should be able to search through. For each term I'd have to list keywords in the database describing the object and it's very likely I could forget a common keyword or include a bad one. Are there pre-created databases that I can use? To specify, let's say I searched the word soccer. Now my result should be words/phrases relating to soccer: soccer players, soccer ball, shot, goal, etc. So I need a search engine for related words or a database containing the relations. It seems like something that could have been done by now so it would much more convenient to use that than to reinvent the wheel. My actual project deals returning activities relating to the word, so having access to the database so that I could modify it would be helpful.


How to effectively do manual debugging?

Say you don't have a debugger available, what would be an effective approach to debug code which doesn't work (as expected)?


Why it is not recommended to have set-only property?

Today at work one of my colleague reviewed my code, and suggested me to remove set-only property and use method insted. As we both were busy with other stuffs, he told me to look at `Property Design` section from "Framework Design Guidelines" book. In the book writer just asked to avoid > Properties with the setter having broder accessibility than the getter And now I'm wondering why it is not recommended to have set-only property? Can anyone clarify me, please?


MPL 2.0. dynamically linking to GPL

Let say that library "A" is published under GPL. Library "A" exposes some API functions for dynamic linking. I wrote a wrapper library "B" for usage of "A" in another language. Library "B" dynamically links to the library "A" (calls are made to the exposed API functions) . I would like to publish my "B" wrapper library under MPL v.2.0. The main question is... is this legal?


Should I keep writing my own code, or get in the habit of RE-USING

this is a general question about programming, I hate using other people's code and I find myself coding things in my own way, even the simplest things like a web template, a PHP calendar, or a news module. Is there anything wrong with that ? Should I change and get in the habit of re-using other people's free code.


What is your strategy for converting RC builds into retail?

We're trying to implement a strategy for how we transition our builds from RC to released retail code. When we label a build as a release candidate, we send it to QA for regression. If they approve it, that RC then becomes our released retail code. I liked the idea of "obvious" labeling of versions so that a user knows whether they have a beta or an RC or retail code... where you would have some obvious watermark in non-retail code (think Windows 7 where the RC or non- genuine builds watermark in the bottom right). ... but it seemed strange to us to manipulate the project (to remove the watermark) once it passed regression. If QA certified version a.b.c.d then our retail code should be that same version, not a.b.c.d+1 what strategies have you employed to clearly label non-release software versions without incrementing your build to disable the watermarks in your retail code? One idea I've considered is writing your build to look for a signed file in the installer archive... non-release code wouldn't include this file and so the app would know to display a watermark. But even this seems like QA is then working with non-release code.   Ideas? **EDIT:** What about a process that QA themselves can run to remove the "RC" indicator? That might be an interesting way to handle it.


Time frame to pass the MCPD Web Developer .NET 4

I have 24 months experience develping .NET C# client/server apps in my profession as Soft developer. Now starting in a new company I have a probation time of 6 months. My new employeer wants to give me 6 month of time to get the MCPD Web Developer 4. If I understood the Microsoft website correctly I have to pass FOUR exams those are:               Web Developer 4 on Visual Studio 2010               Exam number          MCTS prerequisite: TS: Web Applications Development with Microsoft .NET Framework 4          Exam 70-515          MCTS prerequisite: TS: Windows Communication Foundation Development with Microsoft .NET Framework 4          Exam 70-513          MCTS prerequisite: TS: Accessing Data with Microsoft .NET Framework 4          Exam 70-516          MCPD requirement: PRO: Designing and Developing Web Applications Using Microsoft .NET Framework 4          Exam 70-519      Can this be achieved at all within 6 months? I think thats ridiculous. What do you think what is the best way to achieve this? Even more I would like to hear your experience how you have done the "MCPD Web Developer 4"


How to develop a product compare page

I want to develop a product comparison page, where a user can compare 2 or 3 products. I was thinking about a 3 column list displaying every specification. But I want to highlight the differences. I could use a list and sort them alphabetically. And then if element _x_ of list 1 is not equal to element _x_ of list 2 then highlight it. But I 'm not sure every product has the same elements. Maybe element _x_ is missing in list 2. What could be a good method to develop this? Should I mark some elements on every product that can be compared (like a sort of element classes) ? So that I can check if elements from elements class _x_ differ on 2 products. Any other suggestions?


Coded UI test Automation Technique

How is coded UI testing technique more favorable than any other testing technique? What is the main advantage of using a coded UI test?


Should a method's parameter list contain objects or object identifiers?

Our teams is having the following discussion: Let's say we have the following two methods:               public Response Withdraw(int clubId, int terminalId,int cardId, string invoice, decimal amount);          public Response Withdraw(Club club, Terminal terminal,Card card, string invoice, decimal amount);      whats sent over-the-wire are just the ids. one side says that the first method is correct, because we only have the ids of terminal and club, and it should be clear that we have nothing else, this is my approach. the other side says that the second method is correct because it's more flexible. We are familiar with object parameter idea, the other side also thinks that the object parameter should have the objects as properties. Which is the correct approach? Maybe there is a third even better approach?


Why Is it better to use unreadable bytes for client server communication?

I'm composing communication lyrics for client-server and what am I thinking about:   * "authme username passord" (maybe encrytped)   * "accept"   * "get archive of H2O from 03.02.2005 to 20.12.2064"   * transferring binary structure or "error descrtiption" why I always need to do something like   * 0x0FA52FD + CRC   * 0x0D34423 + CRC   * ... I can see some secure reasons but I think it's not the real reason so why I can't use strings in client-server communication?


Recommend a technical book explaining how the browser and server communicate

Although I've been developing web applications for close on 6 years now I still do not know what happens when a request reaches the server. I am looking for book that works through what happens when a request reaches the server and how the server knows which code to call. I'm assuming that there is a old book from the early eighties/nineties, when the internet was still relatively new to developers, that would be able to explain this; but my google-fu is failing me in my search for this book. Whether the book deals with IIS or Apache, I think it would be quite interesting to read and may be useful to know so any recommendations are welcome. Thank you


Faster reads, on an infinite grid plane, than using a hash table?

In the past, I've had alot of success just using a .NET `Dictionary`, with a `TKey` consisting of the X,Y coordinates merged together. However its read performance, despite being amortized constant time, is a bottleneck in a design of mine. My application needs to perform _alot_ of reads, and would benefit greatly if the performance of the read was similar to that of an array. My data has a very high degree of spatial locality; attached is an image showing two graphs of the distribution of some sample data on a 2D plane _(sorry for the lack of labels)_ ; on the left is data with low spatial locality, and on the right is how my data looks (it's always a single connected mass, and blocky in form). ![enter image description here](http://i.stack.imgur.com/AQhJM.png) I could use an array (by computing a bounding rectangle (`bRect`) around the data and then doing `data=array[(y-bRect.Top)*bRect.Height+x-bRect.Left]`) but then I'd have to rebuild the entire array each time `bRect.Height` changed, or `bRect.Width` increased. And so my question is, given the high degree of spatial locality, is `Dictionary` really the best choice here? Is there another approach I could take where I could get near array like read performance, yet not have to rebuild the array when data is added? (I don't need to ever remove data)


How do you deal with Knowledge based questions in interviews?

In technical interviews which interviews experienced programmers , the interviewers ask a lot of knowledge based questions . [eg. Like how to configure this and that in the xml] . These questions have exactly one answer and it is very likely that a good programmer may not know the answer to it (and hence get rejected) . Is there a good way to respond to these questions ? [Like politely telling the interviewer that the answer is just a google search away].


Which is better for small bug fixes and small features - naming branches by ticket number or naming them by feature description?

I am in the middle of a disagreement (cordial, of course) with my lead about proper branch naming. This applies to bug-fix and small feature branches, not long-running feature branches. For long-running feature branches, we agree that human-readable names are better. Here are the two points of view: Mine: Naming branches according to their team and ticket number is better. It makes it easier to find them in our ticketing system, and shorter to type. It also makes it easier to look up relevant branches in GIT when looking for historical information about a ticket. Example:               team-name/12345     team-name/53719      His: Naming branches according to their feature/functionality. It makes it easier to autocomplete, and is easier to remember than individual numbers. Example:               team-name/fix-that-sql-bug     team-name/expand-http-parser      One compromise I offered is this:               team-name/12345-fix-that-sql-bug      But he does not like this, as it messes with GIT autocomplete. If this is primarily opinion-based, please feel free to give me guidance on how this can be a better fit for SO - but I think that the reasons I gave can be amended/added to to give an empirical answer.


Which VCS is efficient for storing small changes to big text files?

A government agency publishes a text file with thousands of records. The entire file is about 60MB. Every day the file has about 60 new or changed records. We need to validate some info against that file, and for auditing purposes, we may need to recover the file as it was in certain date. I thought I could use a VCS to store the file using git, but I understand git stores the entire text file gzipped, so the 60BM file will still need about 30MB to store everyday version. I wonder if one of the free VCS stores only diff/patch files.


User story and Web Service

I am writing a user story and have a simple questions. Consider, I am writing it for login module which calls internally a web service to authenticate the user and returns the data. How this can be converted into a user story. Should this be written as: > As a user, > > I would like to login to the system and see the resultset. and leave it or should I write validations/web service call as well as well. As I understand, as a user I am not concerned with web service. So how should I write about this?


Seeking xinetd alternative for forking concurrent servers in Linux

I recently posted here asking about the drawbacks of having a server process bind to a dynamically assigned port. That approach came about because xinetd, which launched the server process, allocates STDIN and STDOUT as the server's communication channel to the client, and we wanted the server to use a bidirectional socket. The responses (and our operations team) convinced me to abandon that approach. I need a daemon process to monitor a designated port and fork concurrent servers. The server process is written using an I/O infrastructure that is socket-based. We have developed a server process that can be launched by xinetd. The first thing it does is to bind to a dynamically-assigned port number, send the port number to the client over STDOUT, and then listen on the socket for the client's connect() - at which point it is good to go with the socket-based I/O infrastructure. Our operations team has nixed the use of dynamic ports on security grounds (see link). I'm looking for an alternate **way for a client to connect to a dynamically-spawned server and communicate using sockets.** The simplest solution would be something identical in most respects to **xinetd** , but which, instead of allocating STDIN/STDOUT as the server's connection to the client, would pass the socket that was allocated when the daemon accept()ed the connection, to the server. Presumably, since the socket number wouldn't be predictable, the daemon would also need to pass the number as a command line arg. I have written such a daemon in Perl, but I hesitate to roll my own because I'm certain that (x)inetd is far better "hardened" than what I could easily come up with. So that's the problem, and what I conceive to be the simplest solution. I'd appreciate hearing alternate solutions, or even whether in fact xinetd _can_ be configured to pass a socket as I described.


Aren't decorators easily breaking the ISP?

"The Interface-Segregation Principle (ISP) states that no client should be forced to depend on methods it does not use." The decorator pattern is a design pattern to decorate a method of a class. For this, the decorator implements the same interface as the decorated object, so it can take its place. But doesn't this mean that it has to implement all of the methods in the interface, when it uses only one of them, the one it decorates? So I guess it violates the ISP. The only case it doesn't it is when the decorated interface only contains the method that needs to be decorated, but I see it as a rather rare case. An example would be that there are pages in a book. Some pages have footnotes, other pages have titles at the top. So we implement these extras as decorators of a method, let's say draw(). But a page has other methods as well, let's say: fold() and tear() and other methods can come in later. But if we want to use decorated versions of pages inserted in a book, and working the same way, we end up implementing in every decorator every method of a page, where the only thing happening is that the decorator passes the call to the page it's containing.               interface IPage {         public ITearResult tear();         public void draw();     }          class FooterDecorator implements IPage {         private IPage page;              public FooterDecorator(IPage page) {             this.page = page; //the object it decorates         }              //violates the ISP, because it has to implement it, but it's not using it,         //just passes the operation         public ITearResult tear() {             return page.tear();         }              //decorated method         public void draw() {             page.draw();             ... draw footer - the decoration         }     }      Am I not understanding the decorator pattern or the ISP correctly? Is it an acceptable violation or do these two really contradict each other?


Is slower performance of programming languages, really, a bad thing?

Here's how I see it. There's machine code and it's all that computers needs in order to run something. Computers don't care about programming languages. It doesn't matter to them whether the machine code comes from Perl, Python or PHP. Programming languages don't serve computers. They serve programmers. Some programming languages run slower than others but that's not necessarily because there is something wrong with them. In many cases, it's because they do more things that programmers would otherwise have to do (i.e. memory management) and by doing these things, they are better in what they are supposed to do - serve programmers. So, is slower performance, of programming languages, really, a bad thing?


Where to put business logic in MVC design?

I have created a simple MVC Java application that adds records through data forms to a database. My app collects data, it also validates it and stores it. This is because the data is being sourced online from different users. the data is mostly numeric in nature. Now on the numeric data being stored into database (SQL server), I want my app to perform computations and display the results. The user is not interested in how computations are done so they must be encapsulated. The user must only be able to view the simple computed data (for example, A column data minus B Column data divided by C column data). I know how to write stored procedures for same but I want a three-tier app. I want the data that I put into the database as a record, worked upon by performing calculations on it. The original data should remain unaffected, while the new data, post-calculations, must be stored as a new entity record into the database. Where should I write the code for this background calculation? As it is the rules and business logic, should I put it in new JavaBeans files?


How could this diagram for "making a career move into software development" be improved?

I'm giving a talk in April 2011 on "Developer English" and showing my **non- developer audience** , mostly English teachers, various diagrams to explain how developers see their industry etc. One of these diagrams is " **Hot Technologies** ", basically, if you want to become a developer, what technologies should you learn to have the highest chance of (1) getting a **job** (2) making a good **salary** , and (3) work with the most **exciting technology**. This is a draft I made just to get some ideas out, basically C#, PHP, Java are where the bulk of the jobs are. Mobile development has a big future. JavaScript is becoming more and more important, and I want to list "minor technologies" such a Python, Ruby on Rails to the side, I assume e.g. that in general, there are a much smaller percentage of jobs in these technologies as in C#, PHP, Java. **How could this diagram be improved?** ![enter image description here](http://i.stack.imgur.com/iMiOn.png) # UPDATE Thanks everyone for your suggestions. I included most of them in my updated graphic. Does anyone know of more **Java technologies** that would be appropriate here and could anything be added to the **gaming technologies**? ![enter image description here](http://i.stack.imgur.com/ddW6n.png)


Tracking unpaid voluntary effort in open source projects

I am curious if any open source project actually tracked effort by a measure like self-reported hours put by unpaid voluntary coders. Do they? How? Why? I don't care for cost estimations functions of SLOC or any other nonsense variable. I suggest as answer an example with multiple contributors with a explanation of how and why they do that.


How is a .net developer related to customer relationship management (CRM)?

I wonder how can an ASP.NET developer's skills be helpful in customer relationship management? I was going through a job portal searching for jobs in ASP.NET and found that ASP.NET developer skills such as MS SQL, Web services etc were required for CRM Development (could be SAP, Seibel or MS Dynamics). How can an ASP.NET developer be helpful in CRM?


Programmers that need a lot of "Outside Help" - Is this bad?

Is it kind of tacky or poor practice when programmers use an unusual amount of libraries/frameworks to accomplish certain tasks? I'm working with someone on a relatively simple programming project involving geolocation queries. The guy seems like an amateur to me. For the server software, this guy used Python, Django, and a bunch of other crazy libraries ("PostGIS + gdal, geoip, and a few other spatial libraries" he writes) to create it. He wrote the entire program in one method (in views.py, nonetheless _facepalm_ ), and it's almost unreadable. Is this bad? Is this really tacky and amateurish? Am I the only minimalist out there these days?


What's the best way to recruit talented female developers?

I work on a team with a dozen men. They're great. I like them and all, but can't help wonder why it's so hard to find other technical women. I know they exist because I've met them at conferences, read their blogs, and see them on campus. My guess is there's something about our team that keeps them away. How can we recruit talented women without resorting to gimmicks? I'm not looking for complete gender parity, but why is it that some teams have a 50/50 gender split and ours is completely lopsided?


multi-language system and security with php

Firstly sorry for my English. I'm coding new site. İt's like StackExchange, a social site and a blog. Whatever, I try to create multilanguage, however I can't decide how to do it. I have to use modules, so, I must use OOP, while having multilanguage interface. How can I do that? There are two language options (Turkish and English), used continuously (example: home page etc.) or not (some errors; example : "please enter your mail" etc.)   1. I can use a class and I use array (for used continuously),   2. I can use a class and an XML page (for errors), or I can have a class and three language pages: Turkish, English and errors. Which one gives the best performance? * * * Other problem is php-mysql security. I'm using mysqli. Of course I block html characters and I use mysqli_real_escape_string. But they are not enough. So, I use stored procedures. What else can I do? what is your advice?


Should I use the repository in the Domain Object or push the Domain Object back to the Service Layer?

I have come from a transaction script world and I am just starting to take a look at DDD. I am unsure of the correct way to integrate a DDD design with database persistence. This is what I have: A service class called OrganisationService whose interface contains methods for retrieving and saving away instances of Organisation domain objects. Organisation is an aggregate root and has other data related to it: Members and Licenses. EF6 database first DBContext is used within the OrganisationService to retrieve OrganisationDB entities and the related MemberDB and LicenseDB entities. These all get transformed into their domain object class equivalents when retrieved by the OrganisationService and loaded into the Organisation domain object. This object looks like so:               public class Organisation     {         public IList<Member> Members { get; set; }         public IList<License> Licenses { get; set; }     }      I am not using the Repository pattern in the OrganisationService...I am using EF itself as the Repository as it seems that EF6 has largely made repository redundant now. At this point in the design the Organisation domain object is anaemic: it looks like the EF POCO Organisation class. The OrganisationService class looks a lot like a Repository! Now I need to start adding logic. This logic includes managing an Organisations Licenses and Members. Now in the transaction script days I would add methods into the OrganisationService for handling these operations and call into a Repository to interact with the DB, but with DDD I believe this logic should be encapsulated within the Organisation domain object itself... This is where I am unsure of what I should be doing: I will need to persist this data back to the database as part of the logic. Does this mean I should use DbContext within the Organisation domain object to do this? Is using the repository/EF within the domain object bad practice? If so, where does this persistence belong?               public class Organisation     {         public IList<Member> Members { get; set; }         public IList<License> Licenses { get; set; }              public void AddLicensesToOrganisation(IList<License> licensesToAdd)         {             // Do validation/other stuff/                  // And now Save to the DB???             using(var context = new EFContext())             {                 context.Licenses.Add(...             }                  // Add to the Licenses collection in Memory             Licenses.AddRange(licensesToAdd);         }     }      Should I instead just be mutating the Organisation domain object in memory and then pushing it back to the OrganisationService for persistence? Then I have to track what actually changed on the object (which is what EF does to its own POCOs! I am kind of coming to feel that EF isn't just a repository replacement, but also could be the domain layer!) Any guidance here is appreciated.


Documentation in OOP should avoid specifying whether or not a "getter" performs any computation?

My school's CS program avoids any mention of object oriented programming, so I've been doing some reading on my own to supplement it -- specifically, _Object Oriented Software Construction_ by Bertrand Meyer. Meyer makes the point repeatedly that classes should hide as much information about their implementation as possible, which makes sense. In particular, he argues repeatedly that attributes (i.e., static, non-computed properties of classes) and routines (properties of classes that correspond to function/procedure calls) should be indistinguishable from each other. For example, if a class `Person` has the attribute `age`, he asserts that it should be impossible to tell, from the notation, whether `Person.age` corresponds internally to something like `return current_year - self.birth_date` or simply `return self.age`, where `self.age` has been defined as a constant attribute. This makes sense to me. However, he goes on to claim the following: > The standard client documentation for a class, known as the short form of > the class, will be devised so as not to reveal whether a given feature is an > attribute or a function (in cases for which it could be either). i.e., he claims that even the **documentation** for the class should avoid specifying whether or not a "getter" performs any computation. This, I don't follow. Isn't the documentation the one place where it would be important to inform users of this distinction? If I were to design a database filled with `Person` objects, wouldn't it be important to know whether or not `Person.age` is an expensive call, so I could decide whether or not to implement some sort of cache for it? Have I misunderstood what he's saying, or is he just a particularly extreme example of OOP design philosophy?


How to model an arbitrary number of types

I'm currently in the process of modelling a generic form of RNA and RNA transcription and I'm having difficulty finding a proper OO modeling of this area. Human RNA has 4 types of **Nucleotides** (A, G, U, and C). An RNA strand is just a string of these 4 types. eg, AAGACAUUCUA... What I'm trying to model is more generic in the sense that I want to be able to decide the number of **Nucleotide** types at runtime. So, my object model needs to be able to represent an arbitrary number **Nucleotide** types. Initially, I thought I'd just have a **Nucleotide** class which had a **int TypeId** member. This way, I could have a sequence of **Nucleotide** instances of arbitrary types... but this doesn't feel right. I'm not a huge fan of storing type in a variable. I'm also not comfortable with what is essentially _definition_ information being set on every instance (instead of being defined in the a class). So, how do I get around this? Here's what I've come up with so far:   * On a previous project, we would have Singleton objects which represented another object's type. The other object would simply reference the singleton and that was it. It prevented us from having multiple instantiations of the "definition" of our types. Not too great IMO.   * I remember Entity Framework generating Dynamic Proxies at runtime. I could so something similar. I could have a **NucleotideBase** base class and, at runtime, define derived classes. I believe this is possible through reflection. I'm not sure what the performance impact is with this approach, but I would assume it's all just one-time overhead when defining the classes. Are there better, more OO, approaches?


Is it considered bad practice to compile into Javascript as a matter of language preference?

I understand that compiling into Javascript is sometimes necessary and even in some cases results in a faster application. However I'm wondering if compiling into Javascript, for building web applications, from a language like ruby, is considered bad practice. Specifically for the purpose of language preference and for the task of doing typical front-end functions.


UI requires data of certain types. Can it go in a SPROC?

I'm actually arguing against this, but want to see if I'm out of line. We have a PaymentQueue table and a simple UI. This table is, at the moment, primarily used by the UI and no other business logic. The UI requires data that is only in a subset of possible statuses. One developer put this status restriction in the SPROC itself. I'm arguing to put it into the website UI layer, since it's view dependent. The benefit if his approach is it returns less data over the wire, but messes up other processes that may, in the future, utilize this SP, since it now always restricts to certain types. The benefit of my approach is it keeps view logic out of the database, but pulls across more data on the wire (I plan to narrow by date range to minimize this). My thought was to introduce a flag in the SPROC that, if enabled, would filter by these types, thus allowing the SPROC to be more flexible for either case. What is the best approach? Thanks.


Accessible book on functional programming

I'm looking for a book that explains functional programming in an accessible manner. Also I would prefer one that isn't too dull, and doesn't use an esoteric language. Ideally it will use examples that demonstrate situations where functional programming leads to more elegant or simpler solutions than imperative approaches. I have a reasonable amount of programming experience, but no knowledge of functional programming. Thanks for any suggestions


What are the most common algorithms in the field of computational geometry?

So far I've touched on various aspects of computational geometry including constructive planar geometry (locus intersections), algorithms for planar graph topologies, 3D DDA, and most recently a 2D convex hull implementation using Graham's Scan and k-means clustering represented as Voronoi diagrams. It's a fascinating field. I'm interested to know more. I would like to know which algorithms are most common in this field, and what they do.


What does this software do when it says "white labeled routing"?

I am reading about a start-up company that works with online surveys: > Fulcrum is the world’s first complete project management suite to give > clients the power to seamlessly integrate multiple suppliers, increase > productivity and reduce costs. Ranging from vertically integrated research > firms to sample suppliers, clients who license Fulcrum enjoy increased > efficiency and with minimal technology development costs. This simplified > survey management platform boasts white-labeled routing and improved > respondent experience all while giving clients exceptional control and > sample quality. I am a little confused about what's going on. What is " white-labeled routing" ? OK, I found out a "panel" company is a surveying company.


Ruby on Rails downsides and caveats

This is not an opening gambit for RoR bashing - honest! I'm learning Ruby and the Rails framework. Prima facie it appears to be pretty cool, and a wonderful experience compared to PHP. (In fact, it's reminding me of happier days with C# and .NET.) However, going into this, I have no experience with this framework or language, and I'm curious - what are the current downsides or things you'd wish you'd known when you were beginning? (Maybe this should be made a community wiki?)


C# gadgets overloading the form (can't see the woods for the trees)

I have the task of taking over a C# program that is very badly written, however I am new to C#. The form has many objects including labels, buttons, panels, etc, which overlap each other. The form is overloaded with these objects when viewed in Visual Studio while writing the code. I have at least 5 panels overlapping each other, not to mention the rest of the objects. Obviously when the program runs some are invisible when not in the correct mode. How can we separate these panels and other objects in the design phase (say on to a child form) so that they can be viewed only when needed?


Ideal Document Management System

What do you think the features of your ideal DMS would be? I mean list all the features that come to your mind that can be offered under Document Management System.


Is "Mapper" a valid design pattern or is it a variation of the "Factory" pattern?

A common pattern I see is what's known as the `Mapper` pattern (not to be confused with `DataMapper` which is something else entirely), which takes as an argument some kind of "raw" data source (e.g. an ADO.NET `DataReader` or `DataSet`) and maps the fields to properties on a business/domain object. Example:               class PersonMapper     {         public Person Map(DataSet ds)         {             Person p = new Person();             p.FirstName = ds.Tables[0].Rows[0]["FirstName"].ToString();             // other properties...             return p;         }     }      The idea being your Gateway/DAO/Repository/etc. will call into the Mapper before it returns, so you get a rich business object versus the underlying data container. However, this seems to be related, if not identical, to the Factory pattern (in the DDD parlance, anyways), which constructs and returns a domain object. Wikipedia says this re: the DDD Factory: > **Factory:** methods for creating domain objects should delegate to a > specialized Factory object such that alternative implementations may be > easily interchanged. From that quote the only difference I could think of is that the DDD-style Factory could be parameterized so it could return a specialized type of object if the need arose (e.g. BusinessCustomer versus ResidentialCustomer) while the "Mapper" is keyed to a specific class and _only_ does translation. So is there a difference between these two patterns or are they essentially the same thing with different names?


Switch from C# to Java, which "gotchas" I should care?

I may have to switch to Java for new project. I have very little knowledge about Java, because I've mainly studied and used C#, and I'm afraid of the differences between these two language/platform should likely to cause me many problems. Which are the pitfalls/gotchas I should care about?


Handling large amounts of sockets

I am working on a project in which we have a desktop application that should be able to receive commands from a web application. To solve this issue, using sockets seems like a good approach (instead of long polling and various other techniques). The desktop application also uses a web API, and this is secured with mutual authentication in SSL. The sockets should also be secured with SSL. The question is: what is the best way to handle large amounts of sockets? I have thought of a solution which involves using a "relay socket". Basically the desktop application creates a socket to [The Relay Station]. Whenever an action should be sent from the web application, the web app also creates a socket to the relay station. The web app sends a command saying "relay [this] to [socket]". This approach requires that:   * All the desktop-to-relay sockets must be persistent   * The desktop application must identify himself, so that the webapp can reference him in his commands   * The relay station needs to keep track of all the desktop application sockets, and map those to a unique identifier. This gives me a good structure, but it also arises some questions:   * What should the identifier be?   * Is there a better way of sending commands from [WebApp] to the correct desktop application, without using such approach?


Scalability and Programming languages

What makes a language scalable ? I believe scalability is more about system design. It sounds really odd to me, to say that one language is more scalable than the another.


My boss wants a narrated line-by-line English explanation of our code

I have been specifically asked to give line by line (or as appropriate - for example, image by image, etc.) explanation or commentary which my boss wants to be able to read and follow. Since he is not a programmer, he can not follow the code so wants it all translated into English. Has anyone been asked to do this before? I have commented on all of the source code and used JSDoc to generate full documentation of all functions, variables, etc... and included an implementation example, and full working demos with comments throughout. Is there anything else I can do to comment the code for non-programmers? This isn't a reasonable request, is it? * * * ### UPDATE In the end, I managed to explain why it was not a good use of time to do what he was asking. He is a reasonable guy, and just did not have an understanding of what my job involves. Once he saw this post, I think he quickly understood that it was not a normal request. I did provide documentation that is suitable for another programmer to follow (JSDoc and inline comments - as well as some extra notes on technical issues), and a very broad flow chart diagram of the main logic of the program for my boss to follow. In the end, all parties were satisfied and we have moved on.


What are good questions to ask a sales engineer candidate?

What are good interview questions to ask a candidate for a sales engineer position? We're an enterprise software company and the candidate we hire needs to be able to (and I think this holds for any company hiring to this position). I write "customer (programmer)" because the customer is almost always a programmer.   1. Give clear answers to customer (programmer) questions.   2. Focus on how we address the customer (programmer) needs, not list out features.   3. Sound enthusiastic when talking/demonstrating to the customer (programmer).   4. When demonstrating a feature, explain why it is of value to the customer (programmer).   5. Care a great deal about providing quality support to customers (programmers). So, any suggested questions, things to watch for, etc? (Even though a sales engineer is a programmer, what we need is quite different because programming skills can be average but communication skills are very important.)


Progressbar patterns (Eclipse)

I've struggled quite a bit with Eclipse and progress-monitors to try to have good progressbars which report useful progress information to the user. Inevitably the code gets cluttered with lots of things like               if (monitor.isCancelled())         return;          ...          lengthyMethodCall(monitor.newChild(10));      and all over the place I need to pass a `IProgressMonitor` as an argument to my methods. This is bad, for several reasons:   1. The code gets cluttered with lots of code which is not relevant to what the function actually does.   2. I need to manually guesstimate which parts of the code takes time, and which parts do not.   3. It interacts badly with automated tests; where much of the information which goes into a progressbar instead should be logged for later inspection. Is there a way out of this? Are there tools which can help me out with one or more of these problems? Should I be looking at Aspect-Oriented Programming tools, or are there other alternatives?


Is Bubble Sort the slowest sorting algorithm? If the answer is no, then what is the slowest one?


Open source projects, how to choose?

I would like to join an open source project since I think I am good enough at programming to progress onto reading others code and to modify it. But the problem is, how would I choose an open source project to work on? I know many languages and chief ones that I am good are python, C++ (not really very good at C, the lack of object orientation is difficult for me) and Java. For C++, I am proficient with Qt. I would like to start with something that isn't huge, and hasn't reached a phase where the bugs are so complicated it would take me a month to understand what affects the bug. Any suggestions? At the current time, I don't use any libraries in either of the mentioned libraries that I would need to modify (AFAIK).


Is Google Closure a true compiler?

This question is inspired by the debate in the comments on this Stack Overflow question. The Google Closure Compiler documentation states the following (emphasis added): > The Closure Compiler is a tool for making JavaScript download and run > faster. **It is a true compiler for JavaScript.** Instead of compiling from > a source language to machine code, it compiles from JavaScript to better > JavaScript. However, Wikipedia gives the following definition of a "compiler": > A compiler is a computer program (or set of programs) that transforms source > code written in a programming language (the source language) **into another > computer language**... A language rewriter is usually a program that > translates the form of expressions without a change of language. Based on that, I would say that Google Closure is not a compiler. But the fact that Google explicitly state that it is in fact a "true compiler" makes me wonder if there's more to it. Is Google Closure really a JavaScript compiler?


How do early version numbers work for new products?

I'm currently writing a small desktop application for a friend, but I'm doing it primarily as a learning experience for myself. In the spirit of getting educated and doing things The Right Way, I want to have version numbers for this app. My research brought up these related results   * What "version naming convention" do you use?   * How do you version your files (Version Numbers)   * Forked a project, where do my version numbers start? but none of them address numbering of alphas, betas, release candidates, &c. **What are the conventions for version numbers below 1.0?** I know they can go on for some time; for example, PuTTY has been around for at least a decade and is still only at version beta 0.60.


Ways to version user generated documents

I have an online document which essentially gets stored to the database as XML string. I'm thinking about a way to implement versioning of the document for the user. So that user can go back to previous versions of the document. **update** In my case it's a web application with hundreds of thousands of users. A user can store unlimited amount of documents. The XML for document is stored in MySQL blob field so it's not small. Eventually I need to cap the limits somehow but that is a different topic all together. Is there a standard way to approach this? Should I store only the differences between versions? What are other things that I need to consider?


Static Test-Data in Helper Class: Getter vs Public Constant

Currently I am in process of writing large batches of Unit-Tests in the Project I am working on. Additionally we recently Introduced GUI-Testing. This project is a relatively simple webapp, on basis of Java EE 6. Now my colleage did write quite some GuiTests, and I did write quite some Unit-Tests. For both tests we need data to run them. Now we both took different approaches on how we "store" the data we use. **Solution 1:**               public class UnitTestData {          public static final String DATA_PIECE = "some data";          public static final String MORE_DATA = "and more data";          //... and so on     }      **Solution 2:**               public class GuiTestData {         public String getDataPiece() {             return "some data";         }              public String getMoreData() {             return "and more data";         }         //... and so on.     }      My question now is: Which of these approaches is the _objectively_ better one?


Is this the best way to approach this design? Is this an example of MVC?

I am designing a WinForms application in C# and wanted to get a design check by you guys. I am fairly new to programming and have been reading some material, so please excuse my mis-usage of words or 'computer science' terminology if need be. **The Design** I have a MDI application with MAIN as my parent form and various other CHILD forms. Now whenever an exception occurs, whether in MAIN or a CHILD form, it needs to be logged into a LOG window, which itself is a child form of MAIN. Reading material over the web, a lot is said to have loosely coupled classes. Now my thinking is that I will have a non-form class, called **Log Collector Class** which will basically be the "middle man" between all non-log window forms and the window form. Any exception, or update in general to the log window, will need to go through this middle man class. In turn, there will be a custom event in which if this Log Collector Class is updated, the _listener_ , aka the Log Window, will update whatever control it needs to update to display the exception. An image for visual people: ![enter image description here](http://i.stack.imgur.com/FJYgI.png) Any comments on this would be great, especially if I am doing things correctly (or in-correctly).


Concurrency: How do you approach the design and debug the implementation?

I've been developing concurrent systems for several years now, and I have a pretty good grasp on the subject despite my lack of formal training (i.e. no degree). There's a few new languages that have become popular to at least talk about lately that are designed to make concurrency easier such as Erlang and Go. It appears that their approach to concurrency echoes my own experience as to how to make systems scalable and take advantage of multiple cores/processors/machines. However, I find that there are very few tools to help visualize what you intend to do, and verify that you are at least close to your original vision. Debugging concurrent code can be a nightmare with languages that are not designed for concurrency (like C/C++, C#, Java, etc.). In particular, it can be near impossible to recreate conditions that happen readily on one system in your development environment. So, what are your approaches to designing a system to deal with concurrency and parallel processing? Examples:   * How do you figure out what can be made concurrent vs. what has to be sequential?   * How do you reproduce error conditions and view what is happening as the application executes?   * How do you visualize the interactions between the different concurrent parts of the application? I have my own answers for some of these, but I'd also like to learn a bit more. **Edit** So far we have a lot of good input. Many of the articles linked to are very good, and I've already read some of them. My personal experience with concurrent programming leads me to believe you need a different mindset than you do with sequential programming. The mental divide is probably as wide as the difference between object oriented programming and procedural programming. I'd like this set of questions to focus more on the thought processes necessary (i.e. theory) to systematically approach the answers. When providing more concrete answers, it helps to provide an example--something you went through personally. **Goal for the Bounty** Don't tell me what I should do. I already have that under control. Tell me what you do. Tell me how _you_ solve these problems.


Unicode clarification

Why is the length of the some characters e.g. the following 'ᨒ' 3 when it should be 2 ᨒ U+1a12 1a12 means 6674 2^16 is 65536 so 6674 should take only 2 bytes and not three


Performance of single-assignment ADT oriented code on modern CPUs

Working in immutable data with single assignments has the obvious effect of requiring more memory, one would presume, because you're constantly creating _new_ values (though compilers under the covers do pointer tricks to make this less of an issue). But I've heard a few times now that the losses there in performance are outweighed by the gains in the way that the CPU (its memory controller specifically) can take advantage of the fact that the memory is not mutated (as much). I was hoping someone could shed some light on _how_ this is true (or if it's not?). In a comment on another post it was mentioned that Abstract Data Types (ADT's) have to do with this which made me further curious, how do ADTs specifically effect the way the CPU deals with memory? This is however an aside, mostly I'm just interested in how purity of language necessarily affects the performance of the CPU and its caches etc.


Arguments in support of organizational transition to Scala development

I work in an organization that does extensive Java development. Our group is small with a short-lived project, agile development charter. We will leverage existing QA resources of other groups, and potentially contribute code to customers and partners. The primary arguments against Scala development have been:   * QA will need Scala experience   * Customers will need Scala experience My experience has been that Scala is generally easier to read than Java with minimal exposure to the language, and that the ability to use existing Java tools such as Junit would minimize negative impact to existing testing strategies. I've estimated that development in Scala could be 25%+ faster than equivalent Java development depending on the problem. This is just a finger in the wind based on my personal experience. If anyone has evidence of efficiency increase, please share. I would also like to compile a list of major benefits to using Scala over Java. Please share your favorites. Thanks, John


How much time should I devote to my toolchain?

I'm a bit of a tool nut and I'll often spend as many as 6-8 hours a week finding new tools, improving my existing tools by writing plugins or adapters or playing around with new tools to see if I like them any better than the ones I have. That's not counting that my official day job is basically tool-chain development for a large company. Should I be spending this much time trying to improve my tool-chain? What should I be focusing on when improving it to maximize my time?


What is the difference between DI and IoC?

> **Possible Duplicate:**   >  Difference between Dependency Injection (DI) & Inversion of Control (IOC) I'm new to Inversion of Control, Dependency Injection and everything related to these stuff, so excuse me if I'm not specific in my question: Is there any magical piece of code, a good explanation or a link, so I can finally distinguish the concepts? I really think that using Dependency Injection already means using Inversion of Control, but is there any way of using Inversion of Control without using Dependency Injection? I've already read Martin Fowler's articles but I still find the concepts very confusing.


Putting it all together

I've been reading a few books on c# development over the last few months (clr via c#, architecting applications for the enterprise, c# 4 in nutshell just to give you an idea). I really feel it's been a worthwhile exercise however, at the moment, it feels like I've slightly scatterbombed my head with theory (although I have been trying to put it into practice where possible). I have worked on c# projects since .net 2.0 here and there so I have got a few years programming experience, I'm just really making an effort now to try and get to the next level. What I find hard to do sometimes is putting it altogether. What I was hoping to find was some sample project or maybe an open source project or something similar that tries to tie all these aspects of development together in a large project that deals with a fairly complex problem (100s of classes preferably although i know this is not a good yardstick for complexity), in a true object oriented sense, that includes generics, delegates, web services, some different design patterns, linq or nhibernate etc etc, mvc 3/4, with documentation and unit testing... one can dream So is that possible? (edit: without writing it myself)


How much usage of "likely" and "unlikely" macros is too much?

The often known as `likely` and `unlikely` macros help the compiler know whether an `if` is usually going to be entered or skipped. Using it results in some (rather minor) performance improvements. I started using them recently, and I'm not sure how often should such hints be used. I currently use it with error checking `if`s, which are usually marked as `unlikely`. For example:               mem = malloc(size);     if (unlikely(mem == NULL))       goto exit_no_mem;      It seems ok, but error-checking `if`s happen quite often and consequently the use of the said macros. My question is, is it too much to have `likely` and `unlikely` macros on every error-checking `if`? While we're at it, what other places are they often used? * * * Edit: Even though my question is more general, but in my current usage it's in a library that makes an abstraction from the real-time subsystem, so programs would become portable between RTAI, QNX and others. That said, most of the functions are rather small and directly call one or two other functions. Many are even `static inline` functions. So, first of all, it's not an application I could profile. It doesn't make sense to "identify bottle-necks" since it's a library, not a standalone application. Second, it's kind of like "I know this is unlikely, I might as well tell it to the compiler". I don't actively try to optimize the `if`.


Why would each widget need a reference to its parent in a simple widget system?

I'm working on a simple widget system (single window, fixed size). Each widget gets its parent (i.e. the widget containing it) passed into its constructor - except for the root widget, which I called _Screen_. I have some doubts if that approach makes sense. I did it because most of the widget systems I used before do it (Qt, GTK, ...), but I realised that these are quite a bit more complex than mine:   * I have no window resizing   * I don't plan to size containers based on their children's sizes   * I don't think I need it for memory management (I'm using C++), I can use shared pointers instead (basically how it would work in Java) **Is there any reason why a widget would need a reference to its parent?** It's a major refactoring to change this. So before I go ahead and implement containers and layouts, I want to have a good idea of whether or not I'm going to need that parent. **Edit:** Please note that the parent does know all its children anyway, I'm just wondering if the children need to know the parent as well.