How to compute amoritized cost for a dynamic array?

I am trying to understand how to do the amortized cost for a dynamic table. Suppose we are using the accounting method. Let A of size m be an array of n elements. When n = m, then we create a new array of size 4m, and then copy the elements of A to the new array. When n = m/4, then you create a new array of size m/4, and copy the elements to that array. What I am confused about is how to calculate the costs. From what I know so far: Before the first expansion, you pay two dollars to insert. `1$` for the insert, and `1$` you just store with the element, so that you can use that later for a copy operation. Then when you expand it, you use that stored `$` to move the element to the new array. Now in the new array the elements won't have any `$` with them. But now as you insert a new element, you use `3$`. `1$` for the insert, then one more for itself (for a future copy), and one more for the previous element that was just copied. The problem here is, what if you have an array like this: `1$ 2$` Then insert an element `1$ 2 3$ _ _ _ _ _` Now how do you handle a delete operation?


Pros and cons of the following Parsing methods?

I'm thinking of making a Python-JavaScript converter/compile. I've been wondering about the pros and cons of the following methods to parse the Pythonic code, into JavaScript equivalent.   1. Working with the output of `ast.dump(ast.parse(code))`   2. Working with tokens. I've been trying weigh the pros and cons of these methods, but well I'm unable to think of any major one, as I've never used them..   So, Basically could someone help me by telling me what the pros and cons of the two methods I've mentioned above are?   Also, if there is something better that I can use for this purpose, notify me about it.. PS: I'll be using Python to write the converter..


How to connect iPad app to an app I have running in Windows

I recently picked up a macbook and want to start doing some apps for my ipad. I have a chat client written in c# that interfaces a game I play. What I would like to do is write an app for the ipad that would communicate somehow with my c# app. What would be the best approach to this? I have never used JSON but is this where I should be looking? I don't want to spend a ton of time looking in the wrong place, hoping someone here could point me in the right direction.


What recent studies point to the possible improvement a programmer can make as a result of personal character traits?

In Chapter 33, Personal Character of Code Complete (Second ed.) McConnell cites some studies such as those listed below in support of the assertion that 10-1 improvement is possible from efforts in improving our programming as a result of personal determination to improve.   * Sackman, Erikson, and Grant 1968;    * Curtis 1981; Mills 1983;    * DeMarco and Lister 1985;    * Curtis et al. 1986;    * Card 1987;    * Valett and McGarry 1989 As you can see from the list above, these studies are quite dated. Have more recent studies been conducted that studied potential for improvement in programming efficacy? How do the findings compare to McConnell's research? What have these studies revealed about the progress modern methods and tools had in our ability to program?


Universal Standards for Data Interchange - Do they exist and do you follow them?

**Mostly fact and maybe a little bit of opinion:**   One of my pet peeves in programming is data interchange. I work exclusively with small business software (as opposed to working with corporate ERP systems) and I see that many small businesses store contacts two or three times in different types of software where there is little or no interchange. Time clock systems usually don't integrate with calendaring and project management systems. Task management may be in a system separate from project management, or more commonly, tasks are managed on paper or mentally. These are just a few examples of the data interchange problems I see every day in almost every small business. It seems every software company has a different idea about how to store it's data and whether or not to expose that data for interchange and integration. If they do expose some of their data there is really no common standard to facilitate interchange or synchronization. You're always forced to read through the SDK/API documentation if you do want to program some type of integration and then it's almost never a painless experience to get it working and keep it working. It would be really nice to receive an "electronic document" from our vendors that would allow us to quickly enter bills into our accounting system. It would be really nice if we hire a new employee that we could make one single entry somewhere, enter his roles and then he would be entered into all the correct systems even if his information would need to be flagged for review in systems such as accounting. It would be so nice if all our contacts were seamlessly shared between systems so that updating an address or phone number in one of them would make the changes in all of them. **Questions:**   1. Do data interchange standards for common entities such as people, purchase orders, sales orders/invoices, shipping documents, projects, tasks, appointments, etc. already exist?    2. Assuming some do exist, are they commonly accepted, ratified standards?    3. Would you program a business system to use or follow these standards if the initial requirements of the project did not call for it? In other words, how common or accepted are these standards, enough to be followed every time?


In open source jargon, who is a "committer"?

In open source jargon, is a "committer" someone who creates a commit that gets accepted into a project, or is a "committer" a gatekeeper who decides what commits/patches are or aren't accepted into the "blessed" repository?


Can I watch a SHA-256 do its magic visually?

Is there any possible way I can download a program, type in a message, and watch the program display visually what iterations are going on and what formula the character is being fed through all the way down to the output message of a SHA-256 operation or is that just too geeky to ask for?


Multiple sites with the same codebase in Python

I am trying to run a large amount of sites which share about 90% of their code. They are simply designed to query an API and return the results. They will have a common userbase / database but will be configured slightly different and will have different CSS (perhaps even different templating). My initial idea was to run them as separate applications with a common library but I have read about the sites framework which would allow them to run from a single instance of Django which may help to reduce memory usage. https://docs.djangoproject.com/en/dev/ref/contrib/sites/ **Is the site framework the right approach to a problem like this, and does it have real benefits over running separate applications?** * * * Initially I thought it was, but now I think otherwise. I have heard the following: > Your SITE_ID is set in settings.py, so in order to have multiple sites, you > need multiple settings.py configurations, which means multiple distinct > processes/instances. You can of course share the code base between them, but > each site will need a dedicated worker / WSGIDaemon to serve the site. This effectively removes any benefit of running multiple sites under one hood, if each site needs a UWSGI instance running. Alternative ideas of systems:   * https://github.com/iivvoo/django_layers   * https://github.com/shestera/django-multisite I don't know what route to be taking with this.


Licensing for code that I find in forums or on SO?

Let us say, I am browsing the internet and stumble upon a SO answer/forum/blog with code that perfectly solves a problem I have. The only trouble is they didn't specify any sort of licensing for their code. Is this code usable in my project or would I break copyright laws? What would be required for me to include it in a closed source project? An open source project? What licenses would be compliant or non-compliant with it? (e.g. Could I take their code and release it with GPL code?)


Confused about career options in Web Development

I am currently in the final year of my graduation in computer science course. I love programming in PHP but not under pressure. As my graduation life is going to be over I have to shape up my career. My personal desire is to become a web developer and start my own web-based company after completion of courses. I do not have any desire to work for a company as a developer. Currently I have programming knowledge of PHP, Mysql and Javascript. Though I have not completed any type of project in PHP. So to become a complete web developer what else do I need to know to be able to get developement project? Any project I apply for are simply declined due to lack of portfolio. So how should I proceed?


Guided Questioning iOS App

I'm making an iPad app that will display a few choices and based on your choice will display a series of questions with each question triggering a different set of questions. I was wondering if there was a name for this or any open-source library that someone has made for this kind of app. If not, would it be best to hard code all the questions and responses into the app, or to read them from a file?


What is exaclty Timer Deamon in windows? how can i get that using C#?

I have been trying to find the difference between the RTC clock and the system clock. At last I found that Timer Deamon in windows try to compare time between RTC and OS clock. If it is more than 1 min then the time will be updated in OS clock. But the thing is that I want to know what is time deamon exaclty? how can i access that using c#?


Do we need "obvious" Method Documentation information?

I know we have questions about comments in general but I'm specifically wondering about Java Doc style method documentation here. * * * I've been pruning unnecessary comments as I refactor and I've noticed our code has painfully obvious descriptions of methods.               /**     * @name save     * @desc Validates and saves submitted daily plant production information.     */      Most of the "documented" functions are just method names used by convention in our MVC framework (CakePHP). It's inherently obvious that the save method in the Production Controller performs the necessary actions to save Production Information. We don't actually _use_ Java Doc and I question the value of these descriptions even if they were included in Java Doc style documentation. The only reason I haven't touched these because they're method documentation that's _supposed_ to be valuable. The method documentation also hasn't been used _consistently_ , about half of our Controller/model methods are documented. Is there any reason to keep these obvious "Java Doc" comments or should I prune them in favor of "self documenting code" and only make Java Doc comments for less obvious methods?


Nurturing creativity

What is the best development methodology for nurturing personal creativity? Why do you think it's better than others? The methodologies can be agile, traditional or whatever.


How should I develop an unusual user interface?

Say I have an idea for a desktop application with unusual interface requirements. I need:   * Pixel-level control over the look and feel.   * Finely specified custom controls.   * Platform-independence. My typical solution in this scenario would be to use SDL (or SDL+OpenGL) as a graphics framework upon which to build the interface from scratch.   * Is it a good idea to work this way, or should I use an existing toolkit?   * If the latter, which toolkit with bindings for either C or C++ offers the cleanest and most versatile facilities for extension (creating new controls) and customisation (styling existing controls)?


Is it ok to use VS Express edition to create small utilities at work?

I am developer working mainly in C# who has now been assigned to a Data Migration project. (Sad story, I know. But that's for another day). We are currently creating column-to-column mapping between tables in an Excel worksheet in a particular format. Now as many developers, I too hate this kind of mechanical work. I was thinking of creating some sort of small app which will help me in automating this process to a large extent. For this I was thinking of using Visual Studio Express edition as my manager says that the project can't afford a full- fledged VS license. Is it okay to do this considering the license terms of Express edition?


Recommendations on integrating DI/IoC container into an existing application

I am now faced with integrating an inversion of control (IoC) container into an existing application, and I'm looking for some recommendations on how that can most easily be accomplished with the ultimate goal of reducing coupling, thereby increasing testability. Although I generally wouldn't classify most of the classes as god objects, each has too many responsibilities and hidden dependencies through statics, singletons, and lack of interfaces. Here is a bit of background some of the challenges that need to be faced:   * Dependency injection is infrequently used   * Static methods abound - both as factory and helper methods   * Singletons are fairly prevalent    * Interfaces, when used, are not too granular   * Objects often pull in unneeded dependencies through base classes Our intent is that the next time we need to make changes in a particular area, that we try to tease out dependencies which, in actuality, exist but are hidden behind globals such as singletons and statics. I suppose that makes the IoC container secondary to the introduction of dependency injection, but I would expect that there is a set of practices and recommendations that could be followed or considered that will help us break out these dependencies.


How should I communicate the specifics of cloud computing (as compared to other)

A meeting today went well where I explained that cloud computing which one of the persons recognized was something else than a traditional RDBMS and I said that cloud computing is that everthing is software. It didn't seem like "Aha!" when I said it so I wonder what I should say. I thought the main specifics of cloud computing are integrated services, no traditional RDBMS and resources are allocated as software and payment model is pay per usage instead of pay per hardware. And/or should I stress the concept of PaaS i.e. that it is a platform? Wikipedia says the distinction is between products and services but that we said about web services 15 years ago. Thanks in advance for you answers


Can MVC implementations differ in design-details and still be considered MVC implementations?

Is the Model-View-Controller pattern very strictly defined, to it's design details? Or is it a term, like many others, with lots of different interpretations and versions (that all fit the definition)? I have come across many 'versions' and interpretations of the MVC term. For example: Some versions state that using the Observer pattern, the View registers as an observer to the Model. Through this the View gets updates from the Model when it changes, and can update itself. Other versions claim that the View must never interact with the Model in any way. The first version is from the Head First Design Patterns book. The second version I read here on Programmers. Two contradicting interpretation of the specific design-details of the MVC. And there are more examples. My question is: **Is the definition for the MVC pattern one of these terms that are interpreted in a variety of ways, which are all acceptable?** I am not talking about the higher-view definition of the pattern. This has a pretty clear definition. **I am talking about more specific details of design.** Examples: _Should Observer be used to update the View about changes of the Model? Should orders to the View to update be passed to it only through the Controller, or may be told to it by the Model directly?_ Things like these. Do MVC versions vary in these details, but all still fit the MVC definition? Or is it simply that there are lots of 'wrong' MVC implementations?


Is it wise to invest time to learn another technology that you don't need to use at work?

I am primarily from a .net background. During the course of my regular job I find it tiring to keep up with all the relevant technologies (angular js, windows workflow, wcf, Jquery, SSIS, SSRS, asp.net ...). Since most of the top technology companies out there are java based, I am considering making a switch to java. But I am concerned that me devoting time to java might result in me lagging behind in .net (which is very vast ocean in itself). I don't want to spend a few years getting good at java only to realize that I ended up being a jack of all trades and who is not really good at anything. I know I am asking a very general question that may be hard to answer. But I am still hoping, some of the seasoned veterans with many years of experience, can give me some advice on this.


Place measurement data in database (access)

In a software I use records of measurement data. Each record contains basic information like a name, some parameters and the actual measurement data in the form of three arrays of double values that may vary in length from record to record. I currently use a binary format to save these records.   However I am not entirely happy with this approach, since it makes it hard to maintain (there may be changes or additional information in new versions and so on). So I was thinking of moving the data into a database like access. This would have advantages for everyone. I can add information as I want, the user can use the database for other purposes if they please, etc. However I am a complete novice in regards to databases and I wonder how I would structure a database to represent this content, especially the variable arrays.   I thought about encoding the double values into a string (like ; separated base64 strings) but this seems like a dirty hack that's not very user friendly. So my questions are:   * Is a database like Access suitable for my type of application.   * There are no "array"-fields in an Access database, right?   * How is storing a variable amount of data in a database entry usually handled?   * Can I link one Access-Table to an entry in another table? So I would create a Data-table with entries for each datapoint and link this to a specific record in my main table? I hope I could make myself clear somehow, but it's hard to wrap my head around the concepts. If you need more information, please ask. Thank you.


When allowing a user to change passwords, should I generate a new salt?

In my database, I have a column for the hashed password and the salt. My application allows users to change their password. Should I use the same salt for the password, or should I generate a new one? Does it matter to the security of the application?


Is it reasonable to build applications (not games) using a component-entity-system architecture?

I know that when building applications (native or web) such as those in the Apple AppStore or Google Play app store that it's very common to use a Model- View-Controller architecture. However, is it reasonable to also create applications using the Component- Entity-System architecture common in game engines?


How to design routes for generalized/specialized resources

I hope I can explain what is troubling me. Example: I have an object basket with a list of fruit objects. So normally I would build my routes like this baskets/{basketId}/fruits/{fruitId). But fruit is an interface and there are different implementations like apples and oranges that all require their own resource representation. So how do I build my routes now? Like one of those?:   * baskets/{basketId}/fruits/{fruitId}/apple,   baskets/{basketId}/fruits/{fruitId)/orange and so on   * baskets/{basketId}/fruits/{fruitId}/apples/{fruitId} , baskets/{basketId}/fruits/{fruitId}/oranges/{fruitId}   * baskets/{basketId}/apples/{fruitId},   baskets/{basketId}/oranges/{fruitId} What would be the restful way?


Transport information screens

I need to create an information service on trains to deliver live information. I am looking for some ways to go about this. There are already existing LCD monitors in many of the train wagons. They are powered from the battery. When the train is moving, I would like the screens to display the following information: i) about the route, next stops etc. ii) news items iii) video adverts to be shown when the train is within a GPS 'corridor'. For this to work, we need to place GPS on board. We also need to be connected to the internet to be able to get live data (for the news items) and to be able to push new video content when it becomes available. I don't want to have to visit each train wagon just to load up new data. I had originally thought I would need to have an app built in Android that did all this, but I think it would be easier all round if I could get this to work via HTML5 on a browser. So far I have come up with the following 2 hardware possibilities: 1) Buy cheap, 2nd-hand tablets with broken screens (as I should still be able to control it using a mouse). They should have GPS capability either in-built or via a dongle and be internet-enabled (likely a SIM card). Output the display to the LCD screen. 2) Install a laptop with the same capabilities. With 1) it is possible to buy older tablets or with cracked screens etc. so the cost can be kept lower, although it would be impossible to get a standard type (which would be far easier to maintain). They can be bolted onto the back of the monitor. The disadvantage is that the output from the tablet may not be high enough resolution when blown up onto an LCD With 2), a laptop, the resolution issue can be more easily overcome. It also may be easier to source working laptops with broken/missing screens. I imagine that I will need to send information about the GPS location to a server every 10 seconds or so, maybe in a simple GET in a URL, so that I can present the information on a web-page. This might work for information like the next stop, and news feeds, but the videos will likely be longer than 10 seconds. So how do I deliver the content? Among the things I am wondering is if a browser connected to the internet can do all this. The location needs to be continually updated. Instead of simply playing everything on a loop, things happen when the train is in certain areas e.g. approaching/leaving a station. One way to do it is send the GPS data back every 15 seconds and then refresh the browser web-page to display content based on that GPS location and direction. Additionally, would video content cache correctly? When a browser needs to show that content, it would be nice if there wasn't a lot of lag as it tries to download a new video (or display an existing one). And, although using machines with broken screens, which are more cost- effective and less of a target for theft, they become less user-friendly. What happens in the event of a power-outage? It is possible to reboot everything correctly to have the browser displaying everything and connected to the GPS and internet? Lots for me to solve :)


.NET Programming and POCO classes

I was having a think tonight while pondering over some application I need to change and it got me thinking. Entity Framework Entities are POCO (Plain old CLR Objects) and models used in ASP.NET MVC are usually also POCO. This basically means just properties, no methods. Now OO programming normally allows an object to encapsulate its functionality, which includes its properties as well as its methods, this allows for polymorphism to happen. With the rise of POCO classes being used, design patterns like generic repositories have become more popular. When in the past my objects would have had their own CRUD operations, I now have them on a repository. Is this just an evolution in OO where CRUD operations are removed from the objects to allow them to be decoupled or maybe CRUD operations shouldn't have been at object level in the past and I was in the wrong? heck, maybe both are perfectly legit and always have been. Its just an observation that got me thinking, so figured I would seek other opinions.


How to show to management that unit testing is cheaper in the long run than manual testing?

In the company I work for there is a requirement that all the code should be covered by a test of any kind because they want to have as few user reported defects as possible. With this is mind I decided to put a policy that the code should be unit tested to C0 (100% coverage of each line, not each condition). Now others say that this is more expensive that doing manual test. Intuitively I would say that this is wrong as each time you do a change you have to retest everything manually and this is probably more effort than just executing the tests and updating the ones that need to be updated but I don't find a way to justify myself with numbers, papers or other information. Can you give me some good points to proof my approach to the people I report to? **EDIT** : Thanks to all that helped on the question. I see that there were some key points missing on it:   * This is a new product that we started developing one year ago with testing in mind so we use DI everywhere and everything is prepared for testing.   * We already have a commercial product that allows us to reach a 100% coverage as we can mock almost everything, including .Net classes so we can truly isolate classes (JustMock).   * We have tools to calculate testing coverage.   * We are not removing testers and manual testing. We are removing manual testing done by developers. We have a separate SQ team but management wants that the number of bugs that reach the SQ team is as small as possible so developers must reach 100% coverage by any mean before delivering code to the SQ team. So what I did was to replace developer manual testing with automated testing (unit and integration tests) and that's what management wants to revert. **The question is not the same as the "duplicated" one as I already have a 100% coverage requirement.**


OOCSS / BEM / SMACSS architecture

I've been working through this article to organize my front-end code. It references articles on BEM / SMACSS, which in turn reference other articles. I'm really trying to understand what the best practices are ... I have a few days to lay down this "standard", and then have to burn through a high- priority / high-visibility / limited timeline project. As such, I'd like to ensure I'm starting with a foundation that will scale as my app does. Given a component named `segment` ... I'm creating pages that will have ~10 `segments` per page. Each `segment` will share the same base class. However, certain `segments` will have modifiers on them (different background colors). Further, elements within each block (in the BEM approach) will have modifiers as well. To demonstrate, here is a simple implementation (with only a single element `arrow`, while my full site will have 4-5 elements in each `segment`):               .segment__arrow {         position: absolute;         bottom: -24px;         left: 50%;         margin-left: -11px;         background-position: center no-repeat;         height: 21px;         width: 21px;         z-index: 2;     }     .segment__arrow--orange {         @extend .segment__arrow;         background-image: url('/images/arrow_orange.png');     }     .segment__arrow--white {         @extend .segment__arrow;         background-image: url('/images/arrow_white.png');     }      So this is the single-class approach:
 ...
      Alternatively, I could go with the multi-class approach:               .segment__arrow {         position: absolute;         bottom: -24px;         left: 50%;         margin-left: -11px;         background-position: center no-repeat;         height: 21px;         width: 21px;         z-index: 2;     }     .segment__arrow--orange {         background-image: url('/images/arrow_orange.png');     }     .segment__arrow--white {         background-image: url('/images/arrow_white.png');     }      Where my markup would be:
 ...
      Third, I could do:               .segment__arrow {         position: absolute;         bottom: -24px;         left: 50%;         margin-left: -11px;         background-position: center no-repeat;         height: 21px;         width: 21px;         z-index: 2;     }     .segment__arrow.orange {         background-image: url('/images/arrow_orange.png');     }     .segment__arrow.white {         background-image: url('/images/arrow_white.png');     }      And then my class def would be
 ...
      Perhaps even namespacing orange with something like `sa_orange` to avoid loose selectors. The end result I'm looking for is less code / easier to maintain (which probably rules out the single class approach (option 1), as described in this great article on scalable architecture. The multi-class approach (option 2) results in a lot of verbosity (especially in my HTML), but is extremely explicit. The third uses a multi-class approach, but doesn't use namespaced modifiers (like .segment__arrow), so is slightly less verbose (but also less explicit & higher potential for collisions). Does anybody with real world experience with this stuff have any feedback on the best way to approach this?


Good unit test examples for embedded C developers

I'm going to be giving a talk to my department next week about unit testing and test-driven development. As part of this, I'm going to show some real- world examples from some code I've written recently, but I'd also like to show some very simple examples that I'll write in the talk. I've been searching on the web for good examples, but I've been struggling to find any that are particularly applicable to our area of development. Almost all of the software we write is deeply-embedded control systems running on small microcontrollers. There's a lot of C code that is easily applicable to unit testing (I'll be talking about unit testing on the PC rather than on the target itself) as long as you stay clear of the 'bottom' layer: the stuff that talks directly to the microcontroller peripherals. However, most examples I've found tend to be based on string-processing (e.g. the excellent Dive Into Python Roman numerals example) and since we hardly ever use strings this isn't really suitable (about the only library functions our code typically uses are `memcpy`, `memcmp` and `memset`, so something based on `strcat` or regular expressions isn't quite right). So, on to the question: please can anyone offer some good examples of functions that I can use to demonstrate unit testing in a live session? A good answer in my (subject to change) opinion would probably be:   * A function that is simple enough that anyone (even those who only write code occasionally) can understand;   * A function that doesn't appear pointless (i.e. working out the parity or CRC is probably better than a function that multiplies two numbers together and adds a random constant);   * A function that is short enough to write in front of a room of people (I may take advantage of Vim's many clipboards to reduce errors...);   * A function that takes numbers, arrays, pointers or structures as parameters and returns something similar, rather than handling strings;   * **A function that has a simple error (e.g.`>` rather than `>=`) that's easy to put in that would still work in most cases but would break with some particular edge case: easy to identify and fix with a unit test.** Any thoughts? Although it's probably not relevant, the tests themselves will probably be written in C++ using the Google Test Framework: all our headers already have the `#ifdef __cplusplus extern "C" {` wrapper around them; this has worked well with the tests I've done so far.


Implementation difference between Lombok & AutoValue

I thought both Project Lombok & AutoValue used compiler annotation processors, but from this slide presentation and this stackoverflow answer it seems that `Lombok` doesn't? Or at least no only annotation processors? How do `Lombok` & `AutoValue` differ with regards to this?


Performance and data retrieving

I'm currently developing a mobile application in **Objective C** for **iOS** devices. While doing the application I reach the point where I have to retrieve data from a database and show it on a table (the name of a specific workout routine and his description). The way I see it I can do this in two ways:   1. I can select every workout from the database and the associated description, build a collection of objects, send it to the appropriate controller and show in a table all the names, when one is selected I can send the appropriate object to another controller (the one from the next view) and show the appropriate description (this way I just do one operation over the database and manage a lot of objects).   2. The other way of doing this is just retrieving all the workouts names, when one is selected retrieve the associated description from the database and show it (this way I do two operations over the database but manage a lot of less data and objects in the application). What I'm concerned about is performance. Is it better to do more operations over the database and manage less information and objects in the application or is it better to do less operations over the database and manage more information and objects? I know that every application is different and one answer can't be applied to everyone of them, but how should I think about it when developing one? Thanks for your time and help.


Why should one subclass instead of composite when using the Factory Method design pattern?

I'm currently learning about design patterns. I learned about the Factory Method pattern. This pattern means that in order to implement a factory to create objects, one should subclass the class that needs these objects, and have the subclass create them. This way the superclass only works with more abstract references instead of the concrete implementations the subclass generates, which creates a loosely coupled design. This usually means the superclass becomes `abstract`, since it's `createObject()` method must be `abstract` so that the subclass containing the factory method will have to implement this method. Like any factory pattern, this pattern encapsulates the creation of the concrete object, and allows the client to work with a higher level of abstraction. But this specific pattern is built on inheritance. **What I don't understand is** \- Why would anybody go through all the trouble of subclassing the class that needs a factory and making it `abstract`? **Composition is so much better for this purpose in any way.** It makes much more sense to **create an abstract class or an interface called`Factory`.** It would declare one method: `createObject()`. We **create concrete implementations of it for different purposes** (`WeaponFactory`, `TitleFactory`..) Then, we **give the client a`Factory` member instance `factory`.** This reference is **set to whatever concrete`Factory` is needed at runtime**, and the client can simply use `factory`'s `createObject()` when needed (without having to know what concrete implementation `factory` is holding). I don't understand why one would go through the trouble of subclassing a class and making it abstract just for the benefit of allowing it to use a factory in a loosely-coupled manner. The simple composition-based design I described is better in any way - I think. **Do you agree? Could you explain why anybody would use the Factory Method Pattern I described?**


High-Level SQL Interoperability

In a server -> client scenario, wouldn't it be simpler and faster to grant a public user access to a Stored Procedure rather than using web services (XML, REST, SOAP, etc) and other interoperable solutions? That way you could connect directly to a database and get relevant content and do what you will with it in the same way across all languages and systems?


How to describe an n-dimensional cube?

I want to describe an n-dimensional cube (a 2-dimensional cube is a square, a 3-dimensional cube is a cube, etc). I'm pretty sure I need an array, but how do I organise it in the best possible way? So far, I think the best way is to create an array with n dimensions (eg. a square is `$cube [][]`), but I can't understand how to create it. A similar approach may be storing an n-cube as an array of n cubes of n-1 dimensions, which is far more practical (eg. a cube is an array of squares, and each square is an array of points).


Are HSQLDB unit tests an anti pattern?

HSQLDB is great. It (also) has an embedded mode (no dedicated server needed), which allows for quick prototyping of stuff like Proof of Concepts, and it can also be great in production-ready applications, as a quick and simple storage of various data. However, at least 90% of the projects I've worked on in the past years, if they deal in any way with an SQL database, they will unavoidably have unit tests that use an embedded HSQLDB. Sure-enough, these projects (which use the standard Maven structure most of the times), have a ton of "unit tests" (or, at least, some kind of tests, but which are located in the "unit-test" area of the project (like "src/test/java")) which use one or more embedded instances of HSQLDB in order to do some CRUD operations and check the results. My question is: is this an anti-pattern? Does the fact that HSQLDB is easy to integrate and the embedded server is very lightweight make it so that it can be overlooked as "mock-up" of an actual database, when it shouldn't be the case? Shouldn't such tests be treated more like integration-tests (since each of them is composed of "something" _AND_ that "something"'s integration with a database server)? Or am I missing something in the "unit test" definition, and we can infact say that using HSQLDB like this simply adheres to the "mock the dependencies, and test only the unit" part of the "unit test" definition?


Validating Emails in PHP

I wrote the following function to validate emails for a web app I'm working on:               function validate_email($email) {         $valid = true;              if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {             $valid = false;         }              $email_parts = explode("@", $email);              if(count($email_parts) < 2) {             $valid = false;         }         else {             if(!checkdnsrr($email_parts[1], "MX")) {                 $valid = false;             }         }              return $valid;     }      It's not intended to replace the validation email sent to the user with a link to complete the registration. I know it wont catch all invalid ones, it will just reduce them. Hence reduce the amount of bounced emails received. My questions are:   1. Will it flag a valid emails as a false positive?   2. Is it okay to depend on a DNS check to validate the domain?  Any help is appreciated. Thanks.


What programming should I know before college?

I am a student in high school who has wanted to become a computer programmer since elementary school. There are not very many places that teach programming to people my age around where I live, so I am entirely self-taught using resources on the internet such as the MSDN. I have learned and become decent in QBASIC (which I know is very old, even when I learned it), C, C++, C# and have dipped my toes into Java. I get the basic idea behind OOP. I'm planning on going to college and getting a degree in computer sciences, and maybe computer engineering and electrical engineering while I'm at it, because the curriculums are supposedly extremely similar, according to a man I briefly met and talked to from a college. What should I know about computing/programming before going to college? Should I already know a whole lot, know a language or two proficiently, and have fairly high programming/computing skills, or do classes basically start from scratch?


What code format has been verified by case studies as most readable?

Are there any eye tracking case studies, or similar research done to verify what code format is easiest to read, maintain and work with. I always format my code this way.               function thing()     {         if(something)         {           // do something         }         else         {           // do something else         }     }      But, I never see this followed elsewhere. In most APIs or open source projects it's done like this.               function thing() {         if(something) {           // do something         } else {           // do something else         }     }      Can you provide an answer that is not based upon your personal preference, but is supported by research or some kind of fact? **Has there been any visual eye scanning studies done to confirm which format is best?**


Is there a name for this design pattern?

I don't like singletons, but I have to compromise now (but only as temporary measure). However I don't want to go completely singleton. I'd rather want to use this pattern:               interface NameThisInterface {            //Returns the currently centralized object.       static function current();            //Centralizes the instance.       function centralize();          }               class A implements NameThisInterface {        ...     }               $obj = new A;               $obj->centralize();          ...               A::current(); //gets $obj.      Basically A would be my "Application" class. All controllers, models and views etc will access need only one instance of it. But for the sake of easier unit- testing among other reasons I want to have the application object stored as a reference to all MVC classes. So with the pattern above, the conversion at this later point in time will be easier and some of the unit testing might be easier. Is there a generally accepted name for this pattern?


Use Theme/Skin or CSS in Asp.Net

I am working on a website which is using Skin templates everywhere in the page. Because of this all the controls, even labels, are server controls. I was wondering if it is worth changing at least labels to HTML controls and create CSS for them. Is there any advantage of using Skin over CSS?


How to define implementation details?

In our project, an assembly combines logic for the IoC-Container, the project internals and the communication layer. The current version evolved to have only internal classes in addin assemblies. My main problem with this approach is, that the entry point is only available over the IoC-Container. It is not possible to use anything else than reflection to initialize the assembly. Everything behind the IoC-Interface is defined as implementation detail and therefore not intended for usages outside. It is well known that you should not test implementation detail (such as private and internal methods), because they should be tested through the public interface. It is also well known, that your tests should not use the IoC-Container to setup the SUTs, because that would result in too much dependencies. So we are using the InternalsVisibleTo-Attribute to make internals visible to our test assemblies and test the so called implementation details. I recognized that one problem could be the mixup between different concerns in that assembly, changing this would make this discussion useless, because classes have to be defined public. Ignoring my concerns with this, isn't the need to test a class enough reason to make it public, the usages of InternalsVisibleTo seems unintended, and a little bit "hacky". The approach to test only against the publicly available IoC-Container is too costly and would result in integration style tests. The pros of using internals are, that the usages are well known and do not have to be implemented like a public method would have to be (documentation, completeness, versioning,...). Is there a solution, to not test against internals, but keep their advantages over public classes, or do we have to redefine what an implementation detail is.


Interview puzzle on traveling on a line segment

Here's an interesting question I came upon: Let's just say on a number line of length `M`, where `0 < M <= 1,000,000,000`, you given `N` (`1 < N <= 100,000`) integer pairs of points. In each pair, the first point represents where an object is currently located, and the second point represents where an object should be moved. (Keep in mind the `second` point may be _smaller_ than the `first`). Now, assume you start at the point `0` and have a cart that can hold `1` object. You want to move all objects from their initial positions to their respective final positions while traveling the least distance along the number line ( _not_ displacement). You have to end up on point `M`. Now, I've been trying to reduce this problem to a simpler problem. To be honest I can't even think of a brute force ( _possibly_ greedy) solution. However, my first thought was to degenerate a backwards movement to two forward movements, but that doesn't seem to work in all cases. I drew out these `3` sample test cases in here: ![http://i.stack.imgur.com/zRv4Q.png](http://i.stack.imgur.com/dj9l8.png) The answer to the first testcase is `12`. First, you pick up the `red` item at point `0`. Then you move to point `6` (distance = `6`), drop the `red` item temporarily, then pick up the `green` item. Then you move to point `5` (distance = `1`) and drop the `green` item. Then you move back to point `6` (distance = `1`) and pick up the `red` item you dropped, move to point 9 (distance = `3`), then move to point `10` (distance = `1`) to finish off the sequence. The total distance traveled was `6 + 1 + 1 + 3 + 1 = 12`, which is the minimum possible distance. The other two cases have answers of `12`, I believe. However, I can't find a general rule to solve it. Anyone got any ideas?


What is the best C++ interview question?

If you could ask a C++ programmer one question to measure their C++ skills, what would it be? The question I think is best is: **Can you call "delete this;" inside a member function?** (I put this as a link so you can think it through first, then go to The Best C++ Interview Question – Ever! to see the correct answer.) I don't ask this because I expect most people to know the answer. If they did it would not be that useful a question. I ask to see if they can work their way to the correct answer and how they do so.


Sending a collection of data to an API. Multiple small calls vs one big call

I am currently creating an API and implemented a few basic REST actions such as get, update, search etc. Another program that collects data needs to synchronize these to this API. My current thought is: What would be good practice to synchronize this data? A few informations: The amount of data that needs to be synchronized is different between applications. Some may transfer 100 records a minute, others 10k records a minute. There will be a transfer limit per hour to keep the server load balanced. Additionally, requests are signed with a token to check authenticity. Here's a little pro/con list I've made just now. I'm neither sure if these are real pros/cons there nor am I sure if I should weight some of them. **Option One**   Loop through this data and create an API call for every record. Pros:   * integrates better with the current REST API   * failed synchronisation entries can be queued for a resend Cons:   * a bigger overhead because of multiple calls **Option Two**   Build a package of all those data and send over that package in one call. Pros:   * less overhead   * just one query Cons:   * transfer error may drop all data   * separate implementation to allow


When would you need "hundreds of thousands" of threads?

Erlang, Go, and Rust all claim in one way or another that they support concurrent programming with cheap "threads"/coroutines. The Go FAQ states: > It is practical to create hundreds of thousands of goroutines in the same > address space. The Rust Tutorial says: > Because tasks are significantly cheaper to create than traditional threads, > Rust can create hundreds of thousands of concurrent tasks on a typical > 32-bit system. Erlang's documentation says: > The default initial heap size of 233 words is quite conservative in order to > support Erlang systems with hundreds of thousands or even millions of > processes. My question: what sort of application requires so many concurrent threads of execution? Only the busiest of web servers receive even thousands of simultaneous visitors. Boss-worker/job-dispatching type applications I've written hit diminishing returns when the number of threads/processes is much greater than the number of physical cores. I suppose it might make sense for numerical applications, but in reality most people delegates parallelism to third party libraries written in Fortran/C/C++, not these newer generation languages.


Class inheritance and extra parameters

Im trying to create an SMS gateway .. I have a request coming in from a client (web form or API or database record) that I need to process and forward on to a 3rd Party API - or SMS provider. So that things would be simpler going forward I decided to create an interface that each provider implementation would implement :               interface SMSProvider       public method sendSMS(sendTo,message)       public method sendWakeup(sendTo)      I thought this would be my best way forward because then I wouldn't have to change my code when sending to a different provider - i knew that when i create my provider i just call the method to perform the function with the normal parameters and everything is good ... Well until I have a new provider that requires new parameters               new provider requires       - sendTo       - message       - sendFrom       - validityPeriod      So now what do i do ? how can i now use my interface ? when the new provider needs extra parameters ?


In OnionArchitecture can UI talks directly to datastore or not?

I'm fan of onion architecture but looking for some relaxing solutions in some areas. First of all I was thinking about communicating directly from UI (from controller in mvc) to data on the read side. As everyone can see UI should not be referenced to any assembly except Core. When I want to display list of countries on page to select one, that I really need to do this through my Core? I see two solutions:   * UI has reference to NHibernate and talks directly   * add a very thin abstraction layer where I define IFinder<> (only to read data) which will be implemented in infrastructure Thoughts?


method of validating sanity of order dependent values received asynchronously

I have a series of hardware devices that I'm connecting to create paths through. I have some sanity checking to make sure if potential paths are valid and will do what is intended, but to do it properly I need to know what device is the source of the path, and other information from that soruce. Once everything is set up I can infer the source by following the path backwards. However, when I first boot up and infer state, and when I send a request in-parallel to multiple devices, I may get connections out of order; so that I can't trace my connections back to the source because I know that connection A and C exit, but am not yet aware of B so I can't trace C back to A yet. This means it's hard to do the error checking right when I add the connection. My question is how do I do my sanity checking? I have three options, none of which I entirely like 1) trust I do my job right and no bad requests are made 2) try to store the source with each connection when it's created, so I can skip straight to the source for logic checking without tracing the path backwards. This can be done in theory, but I'm afraid that I'm now having to trust that when my pathing logic says something is the source it's right and that source will never change, as well as having logic for inferring source when connections come from the hardware and generally it seems potentially inelegant to maintain. 3) try doing sanity checking as soon as I have a full path (when I add B I now check that B and C are both good), the problem here is that throwing an exception in device B to report an issue with connection made on device C seems...confusing. 4) make connections without validating their sanity, but have someone else in charge of doing a sanity check after all the paths are hooked up (or immediately before)?


Can we create a reference to DOM objects like document.location

As we have a wonderful concept called hooking where we can create a reference to a function and connect another function In the same way can we create a reference to DOM objects. For example can we create a function and **hook** it to **document.location** so that whenever document.location is used the other function must be triggered.


Is adhering to one assert per test foolish consistency in this case?

I have a class that I'm testing. The class has a function: `apply(List<IRule> rules, List<ITarget> targets);` In one test I want to ensure that each target has been passed to one rule, a la:               rule1.AssertWasCalled(fnord => fnord.Test(target1));     rule1.AssertWasCalled(fnord => fnord.Test(target2));     rule1.AssertWasCalled(fnord => fnord.Test(target3));      It seems to me that limiting myself to a single assertion statement would be quite the hobgoblin. Am I correct in this assumption, or is there some other way that I could assert that each target had, in fact, been tested?


How to model an optional input to an activity?

I am constructing a UML 2.0 activity diagram. The activity is to evaluate data from a usability study of a prototype. It can optionally end with just getting the user satisfaction results. But if the company wants to choose which features to implement in the final version, which ones to change and which ones to leave out based on the satisfaction, they also need to do this evaluation. If they choose the additional evaluation, they also need some decision criteria. ![diagram wrong](http://i.stack.imgur.com/8uamv.png) As I understand the UML 2.0 formalism, the object node :classification criteria" in the diagram version above must exist. It has to be there, to be available for token generation, etc. But in my activity, if the company doesn't want to do the "classify features" branch and chooses to end the activity at the flow final node, it doesn't have to prepare any classification criteria before it starts the activity. On the other hand, the criteria are external to the activity, so I can't really put them after an if split, they have to be there at the border. How do I model this situation correctly?


Is it proper to have Investigation task in sprint

I have been practicing agile for more than a year now. As part of our sprint, some times we will have **Investigation Tasks**. We skip poker planning for theses tasks, and adds blanket numbers. Theses are tasks like investigating some tricky defects or technical feasibility of some features etc.. Is this proper or is there any alternative ways to tackle it?


I want to adopt an agile methodology - in a company that has NO process at all?

I'm in a team of two developers and currently we have no formal processes for software development and testing - I'd like to adopt one solo initially. Where I need some opinions is really on the matter of where to begin? Having read various books it isn't terribly clear what the best starting point would be. Recently I put in place a simple sharepoint/access database for recording issues and resolutions, and a changelog. Beyond that, testing is a manual process. In my control is the process by which I design and develop any of my own tools or content and would very much like to adopt a lightweight agile methology that works well for a single developer but is intended to be a "follow my example" for the company to pull all the software development into it. I do like picking out items from various projects I have on the go and refactoring them or adding functionality; one of the notions I was considering was the notion of user stories whereby I could cherry pick out various stories when I was in the general project to which it applies. Anyone else in a similar single developer position who has adopted agile/other 'ology?


A modern review of Java

I've been programming for a few years and I began in Java, and in my time I've found many different sources claiming Java to be an inferior language in some way or another. I'm well aware that each language has it's strengths and weaknesses, but a lot of things I've read about Java seem to be dated. The most often cited reason for Java being inferior is that it is much slower than other natively compiled languages, like C++ for example. Many people criticize the game designer Notch (who developed Minecraft) for using Java because of its apparent lack in the performance department. I know Java was much slower back in the day, but there have been many improvements since, especially JIT compilation. I would like to get some objective opinions of Java as a language today. So my question has 4 parts.   1. Performance. a. How does Java's speed today compare to C++? b. Would it be possible to create a modern AAA title using Java? c. In what areas specifically is Java slower than C++, if at all? (i.e. Number-crunching, graphics, or just all around)   2. Is Java now considered a compiled language or interpreted language?   3. What are some major shortcomings of Java that have been addressed since the early days?   4. What are some major shortcomings of Java that have yet to be addressed? Edit: Just for clarification purposes I'm not making this Java vs C++, obviously on average c++ will be a little faster than Java. I simply need something to compare Java to in terms of maturity as a language at this point in time. Since c++ has been around forever I thought I would be a good point of comparison.


Solutions to problems that .NET can solve better than Java (or vice-versa)

To me it seems these are two different platforms that address similar enterprise(but not only) problems. I'm interested however in problems that Java can solve better than C#/.NET or C#/.NET can solve better than Java. Leaving aside the 'cost' factor, since that is somehow not an issue for big enterprise companies (the developers probably cost more than the licenses from Microsoft - it's just a thought) and even for small projects there are free/open-source tools for .NET so the cost can be zero for the .NET world as well. With Mono, you can port .NET to Linux and MacOS as well so the benefit that Java had(cross platform) isn't THE decision factor to use Java nowadays.. What real world problems can you think of where .NET would be a much better solution than Java, and vice-versa? I'm only interested in solutions to problems.


Open Source Licenses

I'm independently developing a physics-based game using HTML5 canvas and JavaScript; I've used no external code at all (including physics or game engines), and my code is about 5000 lines in length. The development is almost complete, and now I want to release it. I am planning to release the game as a paid app on the Chrome, Android, and Apple app stores, but I also want to release the code under an open source license - one which allows free reading and gleaning of ideas from my code, but does not allow more than a couple lines to be copied. Basically I want people who know where to look and how to use to find free code, and the general public to buy it, while preventing piracy or the development of a near copy. Is this possible with an open source license? What license should I use?


Creating a New Scripting Language For the Learning Experience?

Is creating a scripting language for my own personal learning experience worth it? The reason I ask is that there are so many programming languages available already, I know mine will never have any actual use other than providing a good learning experience. I do, however, see drawbacks with just trying to make a scripting language as a learning experience: it will take a lot of time and effort in which I could be doing something more "productive." Would creating a programming language (including writing drafts of its intended purpose, syntax, philosophy, interpreter, etc) be worth the time, effort and learning experience? Or are there other projects I could benefit more from?


Why do web sites require certain characters in their credentials?

It seems like when web site lists requirements as to what characters MUST be in the password they're only providing a password map for someone who wants to hack their system. For instance, fsd.gov requires:               The password must be 10-14 characters in length.          The password must contain two each of the following:          Upper/lower case letters, numbers, and special characters.          An example of an acceptable password is:  AAbb1234!@      Congrats! If I wanted to hack your password, now I know that trying to guess "aaaaaaaaa" will be wrong, you've given me clues as to what I can guess and helped narrow it down. It seems to me like it's more open and more possible combinations if they didn't require special characters. Then if you included one your account is now more secure. _Note - As you've probably guessed, I'm not a pro at security, which is why I posted here._


A multi tenant data architecture

We are at a planning & redesign stage of our loyalty card application. As it is understood it will be a multi-tenant application. And I need to take your thoughts. Here are the some key points we should take in to account to redesign logical and physical data structure:   1. Campaigns: We may organize cross tenant campaigns like if you buy this from tenant A you may buy that from tenant B with 10% discount.    2. Tenant Hierarchy: From the security point of view branches of tenants can only see their transactions not the other branch or tenant.    3. Customization for tenants will be rare to be ignored: We consider customization will be on card holder data only (at least we will not have a chance to make customizations per tenant base in next one or two years).   4. Card holder (not a tenant user, Also we may login for administrating and reporting all tenants) may login to system to see the transaction she made.  In general i agree with the idea of separating tenant dbs or sharding at some level. Since we have #1 criteria, it requires us to query all dbs to decide whether her transaction is shooted a campaign or not. It may be a huge performance problem. Or what do you think about sharding, does it really make performance issues? Also what would you prefer if you have to create OLAP system you have to query on multiple-sharded db for reporting and decision making purposes? On the other hand with separating db, more active tenants will take more performance gain from system especially while taking reports. Because their transactional data will reside in their own db and one query will be executed. We may allocate more resources on system and quote meaningful price for their usage of application. Sharding will also be helpful if we consider to place this app on cloud because sqlServer azure has limit of 10gb per db. One idea is separating dbs but maintaining a master db for cross decisions like campaigns etc (like the one mentioned here at edit part of the question). But all reports will be taken from the dbs they owned. A second idea is separation of much more active tenants and handling the others by tenantID approach in master db. Lastly we may consider nosql graph db to process transactions on campaign server. We will also be using NHibernate for ORM tool. But sharding project left undone and we should take into account to implement one for us to implement seperate db approach using sharding or master db approach. What do you think about using nhibernate at transaction handling service? Will it be a performance penalty using NHibernate in a real time service that should perfom high speed response? If so what would you suggest? ## EDIT @rae1n To be more understandable on my certain needs : 1 - According to key point i mentioned above what data architecture would you suggest ?   * One db and TenantID per table, replicate the db when needed.   * Using shards with master table.   * Using mix of sharding and tenantID.    * Your own suggestion. 2 - Is NHibernate suitable for you suggestion for #1 and how? Could you please suggest a sample app or link to a article ? 3 - Is NHibernate suitable for campaign assessment service. Please take into account that there may be very complex campaigns amoung 1 to n tenants and we should support these behaviours. 4- Would you suggest nosql graph db for campaign assessment and do you know a sample for that usage?


How is type checked in a dynamic language interpreter/compiler, such as JavaScript?

In dynamic languages, such as JavaScript or Python, the type of a variable is determined at runtime. This is one reason why they are slower than typed languages such as Java. How is type checking performed? What is the essential reason this process is slow?


Managing contractors on Github

I want to manage outsourced contractors to help develop our code. The code sits on Github. I wish to use a simplified version of this branching model: http://nvie.com/posts/a-successful-git-branching-model/ For now, the code is not modular, so I cannot hide parts of it from some developers, a la http://stackoverflow.com/questions/3852601/github-branches I do want to hook up our production and staging servers to a repository, so I need to manage write access to the code repository. Q1 - does this mean I need an ORGANIZATION account on Github? I'm assuming I do. Q2 - Would this branching methodology work: A `Main` repository with the `Master` and `Integration` branches. Contractors (not having write access) will pull from this repository (or fork it?). When they are done with a task, they will send a pull-request via the site. Q2A - does this mean I will not have the ability to track task branches in my repository?   Q2B - how will the integration process work? Do I need to assign a new team, called integrators? Will they pull the completed tasks to the integration branch of the main repository, test it and if good merge to the master branch? Q3 - Is there a better model? **EDIT** \- I trust these developers with my code (with regards to secracy). I do not trust them to decide when a feature is ready for production, or which fixes go into the next release. Thanks! Tal.


Explaining floating point precision to customers

What is the best way to explain floating point rounding issue to **_customers_**? I know http://download.oracle.com/docs/cd/E19957-01/806-3568/ncg_goldberg.html as well as the entries in the C++ FAQ and various other pages aimed at developers and scientists, but is there a web page, article or explanation, aimed at "regular" customers with limited mathematical or scientific background? (for which the above references fall flat). If it were maintained or coming from a well-known and well-recognized institution or corporation, all the better, given that, as some of you might have experienced, it can be a little complicated to explain that yourself.


Why Functional Programming

What is the deal with functional programming? I see talk about it a lot but to be honest I've never found them at all useful. Why do so many universities apparently teach them?


How do you handle increasingly long compile times when working with templates?

I use Visual Studio 2012 and he have cases where we added templates parameters to a class "just" in order to introduce a "seam point" so that in unit-test we can replace those parts with mock objects. How do you usually introduce seam points in C++: using interfaces and/or mixing based on some criteria with implicit interfaces by using templates parameters also ? One reason to ask this is also because when compiling sometimes a single C++ file (that includes templates files, that could also include other templates) results in an object file being generated that takes in the order of around 5-10 seconds on a developer machine. VS compiler is also not particularly fast on compiling templates as far as I understand, and because of the templates inclusion model (you practically include the _definition_ of the template in every file that uses it indirectly and possibly re-instantiate that template every time you modify something that has nothing to do with that template) you could have problems with compile times (when doing incremental compiling). What are your ways of handling incremental(and not only) compile time when working with templates (besides a better/faster compiler :-)).


How to adopt scrum agile methodology for a small .Net team

I am working on a small product based company developing .Net applications. There is a small team with 5-6 developers. I am a person responsible for planning everything. But my primary role is Software developer. Now our current project is very unstable because of poor organization. Today my boss called me and told to submit a report about required resources, appropriate methodology, required man power and their salary scales to make the current project success. I know I don’t have enough organization skills and I need to go deep in my programming skills. So I need to focus only in the development. So I can’t manage the project anymore. Now I am searching some other ways to make ongoing development success. My questions are   * What is the suitable agile methodology to my team?   * Is Scrum is suitable for above mentioned scenario?   * If we adopt Scrum, what we have to do next? (I think hiring new one to manage the project is more suitable. So we have to get Scrum master and some other developers.)   * Are there any resources (books, Blogs and etc) to get some tips and advices to solve this problem?   * If Scrum is not a suitable methodology for our scenario, what else can be more suitable methodology to adopt? Can anyone give a good solution for my problem?


Should devs, testers and business users have one unified test script?

In development, I would normally have my own test scripts that would document the data, scenarios and execution steps that I plan to test; this is my dev test plan. When the functionality has been deployed to Test, testers test it using their own test script that they wrote. In UAT, the business user then tests using their own test plan. In retrospect, it looks like this provides a better coverage, with dev tests having a mix of black and white box testing, while testers and business users focus on black box testing. But on the other hand, this brings up distinct test cases that only are executed per stage (ie. some cases which testers thought of are only executed on Test stage) and it would like the dev missed it, which makes it a finding/bug. Is it worth consolidating the test scripts from the start? Thus using one unified test script, or is it abit difficult to do this upfront?


Private variable vs property?

When setting a value to a variable inside of a class most of the time we are presented with two options:               private string myValue;     public string MyValue     {        get { return myValue; }        set { myValue = value; }     }      Is there a convention that determines how we should assign values to variables inside of our classes? For example if I have a method inside the same class should I assign it using the property or using the private variable. I've seen it done both ways, so I was wondering if this is a choice or performance is a factor (minor, probably).


Changing from VB.NET to C#?

I am working on co-op at a company as a test engineering specialist. This is not technically a software job, however at the end of the day, I spend most of my time programming. I am not a programming wiz by any means, but I am very comfortable using VB.NET since that is what projects started at my company previous to my time were written in, and so it is what I have learned and used in the position. I have gotten the feeling from my time searching for help online when I need it that there is generally more and better support for C# than there is for VB.NET. This has led me to thinking that it may be beneficial for the company going forward to start programming less in VB.NET and more in C#. However, almost all projects in my department (since several other people work on small programming projects) are currently written in VB.NET. Additionally, most of the software design done in our department is relatively simple I would imagine relative to a software focused area of any company. Probably half of it is generating html pages with graphs to visually illustrate certain data. Taking these two facts into account, there are obvious disadvantages to trying to switch the main programming language used. Also, the vb.net language is very similar to VBA (for excel) and VBScript, which are also used quite a bit in my area of the company. I am basically not sure if it would be worth the work to change the main language used since there is not a lot of complicated programming done, and similar languages are necessary anyways it seems. I was curious what additional insight experienced programmers may be able to offer me regarding changing the main language used in my area from VB.NET to C#? What benefits or disadvantages are there that I may not have thought of? How big a role do each advantage and disadvantage play? What is your overall opinion on the idea of changing from VB.NET to C#?


When we talk about 'a closure' do we refer to a single variable, or do we refer to all 'closed' variables?

Let's take the following (JavaScript) code that returns a function that closes over variables `x` and `y` to illustrate:               function test() {       var x = Math.random();       var y = Math.random();       var f = function() {          console.log(x, y);        };            return f;     }     test()();      _The code is nonsensical, I just want to close over`x` and `y`._ Variables `x` and `y` don't exist outside of the function `test` but they remain available in the function `f`. Barring any compiler optimizations (like inlining), do we say there is a single closure ( _created by_ `f`), or do we say there are two closures ( _for/over_ `x` and `y`)?


What is the reason behind the if syntax of CoffeeScript?

In most other languages the condition comes before the statement to be executed when the condition is met. However, in CoffeeScript (and maybe some other languages) the syntax is:               number = -42 if opposite      Is there any online documentation of what the logic behind this design decision for this syntax was?


How to Subtly Tell a Professor About our Poor Programming Assignments?

This is related to my C++ teacher of semester one and, unfortunately, the coming second semester as well. I have already completed the first assignment; needless to say, it's horrible. How can I gently tell my professor that the homework he is forcing us to do is giving us a bad example of good OOP as well as bad OOP practice in C++. For example, he is forcing us to class all of our functions, use get/set methods for all members and painstakingly horrible functions to call our data. This is an example of the homework project we have to do:               AuctionApplication aA;     Auction *auction = aA.CreateAuction("Hello");     Bidder *bidder   = aA.CreateBidder(", World");     Bid *bid         = aA.bid(bidder, auction, 0);          std::cout << "Auction:  "  << aA.GetLatestBid(auction)->GetAuction()->GetName()               << "\nBidder:  " << aA.GetLatestBid(auction)->GetBidder()->GetName()               << "\nPrice:  "  << aA.GetLatestBid(auction)->GetPrice() << "\n\n";          std::cout << "Auction:  "  << bid->GetAuction()->GetName()               << "\nBidder:  " << bid->GetBidder()->GetName()               << "\nPrice:  "  << bid->GetPrice();      Every single function must have a non-void return type, I cannot simply retrieve any data whatsoever without jumping through hoops. Above that, it's not even encapsulated properly, as I can easily get a bid member and then, if I was an unknowing programmer, continue programming with said value. There is no const-correctness, there is no efficiency (everything is pass by value, even vectors and lists), there is no exception safety, nothing whatsoever. The homework assignments are bug-ridden and goes against the nature of C++, which is, in my opinion, OOP in moderation, as it demands. I'm not sure if it's me, and how my other classmates feel about it. I know my friend feels the same way, but most of the class is struggling as it is with a fail-rate of 60% on exams. Is there any way I can tell my teacher to try and give better assignments in a more C++ style environment without possibly raising his ire? Posting this in Programmers as opposed to SO since the question deals with how to talk to programming professors, not write actual code :)


Does being a software tester make you a more well-rounded developer?

I'm interested in the prospect of spending a few years as a tester: it seems like two or three years as a tester in anyone's CV is a big gain. Are there any skills you can get as a software tester which you can't (or certainly won't) get as a developer? Is there a way back from software testing to development or do most companies prefer "pure" developers?


How do newly-created programming languages use Windows API features?

WinAPI is focused primarily on the C family, but how do new programming languages use those features without creating their own runtime/interpreter type thing? Do they hook directly into the DLL files? kernel32.dll contains most of those functions right? Thanks.


Are python's cryptographic modules good enough?

I mean, say you were writing professional grade software that would involve sensitive client information. (Take this in the context of me being an amateur programmer.) Would you use hlib and hmac? Are they good enough to secure data? Or would you write something fancier by hand? Edit: In context of those libraries containing more or less the best hashing algorithms in the world, I guess it's silly to ask if you'd "write something fancier." What I'm really asking here is whether it's enough on its own.


Best way to make synchronous calls between JEE apps

I have two jee web apps that are going to be published on the same physical server, but on different network addresses. **APP A** : Listens to a port on a public IP address and makes synchronous invocations to app B if necessary. **APP B** : Listens to a port on a private IP address and makes synchronous invocations to app A if necessary. ![enter image description here](http://i.stack.imgur.com/zfoDg.png) For connecting APP A with APP B, I am considering the following alternatives.   * RMI    * Message Queue    * Lightweight ESB Please tell me if you see any clear advantage supported by facts on any of them, or if there's another technology I should consider.


Strategies to avoid data entry duplication between PDF vs. website (e.g. restaurant menus)

I'm building a website for a restaurant. They have a downloadable PDF version of their menu (which is what the "real-world" menu is printed from), but we also want to have a text-based version of the menu on the website (because it's the 21st century and you shouldn't have to read a PDF when browsing a site like this). I'm hoping to avoid -- or minimize as much as possible -- the potential problems with maintaining data in two places (one in the PDF and one on the website). In an ideal world, we'd build a custom dashboard interface for managing menu data, with a fully-normalized schema, and from that data we'd automatically generate the PDF _and_ the website versions of the menu (and come up with a very expensive and flexible visual design for the PDF menu that takes into account all future permutations of data that may be contained within it -- because the visual layout of the PDF menu is very important, since that's what the "real-world" menu is printed from). But, since the budget is not unlimited, I'm trying to think of other ways to accomplish this goal. Are there any compromise solutions or "this gets you halfway there" kind of things I could do? Obviously I'm not expecting a perfect and cheap solution, but anything that minimizes the double-data entry to the extent that it's not so much of a chore would be really helpful.


Devising test of Haskell's value/reference semantics

In imperative languages, it is trivial to devise a programming test of language's use of "value semantics" or "reference semantics". One could do the following and check the value of `a` (where `Vertex {one, two, three :: Integer}`):               a := Vertex 3 4 5     b := a     one b   :=  6     two b   :=  8     three b := 10      However, since variables are immutable in functional languages, this test won't work in such languages. I know very little about Haskell (and functional programming in general), but my understanding is that it uses value semantics. Is it possible to devise a programming experiment that would distinguish between a "ref record" and a "val record" in Haskell?


Advices on structure and names for namespaces and classes

I'm resistant to calling the "main" class the same as the namespace, but I sometimes find myself needing it. Considering I'm using the `Vendor.Namespace.[Subnamespace].Class` formula, imagine this scenario:               [MyFramework]         [Database]             Database             Sql             Schema             DriverAbstract             DriverInterface             [Drivers]                 Mysql                 Postgresql                 Sqlite      obs: `[]` are for namespaces, the others are classes. Now, I could call the `Database` class `Connection` instead, but when I import the namespace `MyFramework.Database` I would only see `Connection` in the code (but connection to what?). Other solution would be calling it `DatabaseConnection`, but is that really necessary? I would like to hear your thoughts and ideas on that problem. Thank you (: Sidequest: also, what are your thougths on `DriverAbstract` and `DriverInterface`? Should they fit better in the `[Drivers]` namespace? Should I call `DriverAbstract` just `Driver`?


When is Efferent / Afferent coupling good or bad

I have a software patterns exam this week and one of the topics we are to study is Efferent and Afferent coupling. I understand a package has a high Ce (efferent coupling) if it depends on a number of other types. For example:               class Car{         Engine engine;         Wheel wheel;         Body body;     }      This class would have a high efferent coupling because it depends on the Engine, Wheel and Body types. Whereas the type "Wheel" would have a high Ca (afferent coupling) if several other packages depended on it (Car, Plane, Bicycle). One of the possible questions on our exam is, when is Efferent / Afferent coupling good or bad? This seems odd to me because logically a program would need packages / classes with both high Efferent / Afferent coupling. Does anybody have an example of when / where high efferent or afferent coupling is good / bad?? Thanks !


How does a priority_queue maintain a heap on a deque efficiently?

In the C++ STL, `priority_queue` (heap) can be used with any underlying container, such as a `deque`. How does the implementation stay `O(log n)` if `deque`s don't swap an item in index `a` with index `b` in constant time?


Simplifying the process of compiling and running objective-c apps in GNUstep

I just installed GNUstep (following this post: http://www.jaysonjc.com/programming/objective-c-programming-in-windows- gnustep-projectcenter.html) It says to run this code:               gcc -o helloworld helloworld.m -I /GNUstep/System/Library/Headers -L /GNUstep/System/Library/Libraries -lobjc -lgnustep-base -fconstant-string-class=NSConstantString      every time I want to compile. It works just fine for me. However as I'm learning and will be compiling/running apps way often (making little changes and trying again), I'd like a simpler way to do this. Is there an easier way to compile and then run the app? Or am I just being lazy?


What's the best structure for a repository?

I've looked into many open source software repositories, and I've found some common elements and somethings people do in different fashion from one another. For example, every repository has a `README` file, a `INSTALL` file, a `COPYING` file and stuff like that. Other things differ:   * Some projects, like git, have their source code in the root level, while others have the source code in a `src/` folder and others, like the Linux kernel, have the source code spread in different folders in root level, that divide code by areas;   * Some have their tests in a `t/` folder, while others in a `tests/` folder, or named otherwise;   * Some have files about submitting patches and who the maintainers are, and those might be inside some `Documentation/` or in the root level. Are there recommendations? A best practice? For example: personally, I don't like the code in the root level, git-fashion. It looks messy and confuses one trying to start as a contributor (especially because they have some code inside folders, and scripts in the root level as well, it's really messy). If I were to start a project of my own and wanted to start right from the start, are there recommendations? Best practices? How can I make a clean and clear structure? Thank you!


test for graduate software developer role?

I'm looking for tests that are suitable for a graduate software developer role, mainly tests that are about reviewing code and finding faults and etc, multiple choice or otherwise.preferably code written in c#. I have a test coming up soon and want to prepare before hand.


why javascript is widely used scripting language in web applications?

I cant find plugins written in other languages other than javascript. There is browser support only for Javascript. Why didn't they use other scripting languages other than Javascript when people started using scripts on their web pages? Why javascript was given priority?


Why do we still use JavaScript?

> **Possible Duplicate:**   >  Why aren't there other client-side scripting languages for websites? It seems to me that, despite being one of the world's most used languages, even some of the leading experts of JavaScript like Doug Crockford think JavaScript suffers from some pretty big design flaws ( _JavaScript: The World's Most Misunderstood Programming Language_ ) that make development confusing and ambigious. Programming languages and development tools are always getting better and make it much easier for developers to make things. There's a new version of .NET every few years, new version of HTML5 with new tags, new versions of CSS, etc. Why hasn't there been a better version of JavaScript or another dynamic loosely typed language, but without all the design flaws, come out to supercede JavaScript?


Why aren't there other client-side scripting languages for websites?

Why is there just support for JavaScript and some VBScript in browsers today? I know JavaScript is good and all, but wouldn't having the option of using another programming language help promote different development styles?


What are the essential Clojure libraries to learn beyond the basics of "core"

I am teaching myself Clojure. I've started using Leiningen, I'm working on Clojure Koans, plan to do LabREPL next, and will have a look at Noir. My question is: what are the essential "must know" Clojure libraries and functions to know beyond those covered in the above learning plan? Looking at Clojure Contrib, there are large number of libraries. As a professional (or OSS) Clojure developer, which do you find yourself using on a daily basis? Which ones are not so useful or otherwise not commonly used (i.e. are esoteric / do not come up often in day-to-day coding).


How to introduce a computer illiterate 50-year old to programming

The other day my dad asked me a question that I would have never expected from him. "How can I learn C++?" My dad is turning 56 this year and computers are a distant concept for him. He doesn't know how to use a phone very well besides calling numbers (no speed dial or contacts); though he has started to learn computers a little better - to the point that he knows how to open the internet (in Windows) and browse around (and has successfully completed several job applications entirely on his own online, of which he was offered positions too). But still, these are too narrow-windowed experiences to mean much, really. While he may not have the background, my dad knows how to read. And I mean reading as a skill, not just an ability. He has little to no college education (financial problems, family, etc.) and was fortunate enough to finish high school, but still taught himself to become a master electrician and has been one for almost 30 years now. He did the same with guitar, learning to play at a very professional level and has been praised for his skill. In high school, he picked up a weight lifting book - and was the only person in his high school at the time to qualify officially as an "athlete" by national standards. In all cases, he just needed something to read. Something to teach him. He absorbs information like a sponge. I have no doubt in my dad's motivation or capability of doing this, so my general goal is simply: **Get my dad into the world of computers, and get him on the road to programming.** I strongly believe that once I get him through the fundamentals, his drive and reading skill will keep him going on this own. So I'm asking you all: where should I start with all this? And what are the best resources out there? Should I get him to start Linux instead of Windows? Is C++ a bad idea? Remember, he needs to (IMO) learn computers first, and then get that first grasp (the "Hello world" experience) of programming. For money's sake and at top preference, I'd like free online resources that he can read, but by all means any good suggestions in print or paid-for-online are welcome (that I could possibly look into later to purchase). And also, I intend to start him off with C++ (no Python, Java, etc.), because I know it the best and will be able to help him along the way with code. (I have minimal knowledge right now in other languages). Edit: I'm getting a lot of persistent suggestions to use Python. The only reason I wanted to do C++ is that I KNOW it and can be THERE when my dad needs help. My VERY FIRST exposure to programming ever was Java. I learned Java, and I got good at it. I open to other suggestions, but please provide an effective application of your suggestions. EDIT #2: I understand my approach/thinking/knowledge could be lacking here. I'm a sophomore level undergraduate CS major. If you don't agree with anything in my post, tell me why - give me ideas, information - that's why I'm asking in the first place. To narrow down my general goal to specific reachable goals.


Python for large projects

Are there any resources out there on how to architect large, industrial strength Python projects? I'd like to start on an ambitious personal project, but I'm not really sure how to architect it and what practices to put into place to make the project successful. Are there any resources out there discussing how to make large Python projects work?


Understanding the DIP, DI, IoC theory

For about 2 months I've been reading everything I can find for these 3 topics and I'm not yet sure I got it.   1. **Dependency Inversion Principle**. Means you should always only rely on interfaces and not on their implementations. If your class depends on any other class, that's bad, because it depends on that second class' details. If your class depends on interface, that's absolutely OK since this kind of dependence only means that your class needs something abstract that can do something specific and you don't really care the way it does it. Since P in "DIP" stands for "Principle", I should probably define it this way: **Dependency Inversion Principle is a principle that requires all your code's entities to depend only on details they _really_ need**. By "details they really need" I mean interfaces for the simplest case. I also used the word "entities" to emphasize that DIP is also applicable to procedures and whatever else, not only to classes.   2. **Dependency Injection**. It's only applicable to DI-enabled entities. DI-enabled entity is an entity which is "open" for configuring its behavior without changing its internals. There are 2 basic kinds of injection (when talking about classes):     * Constructor Injection - is when you pass all the required "abstract details" to the object just by the moment it's about to be constructed.     * Setter Injection - is when you "clarify" the required aspects after the object has already been created. So, the definition is probably like following: **Dependency Injection is a process of passing the "abstract details" to the entity that _really_ needs these details**. By "really needs these details" I mean interfaces for the simplest case. The word "entities" is, as always, used to emphasize that DI is also applicable to procedures and whatever else.   3. **Inversion of Control.** It's often defined as "difference between libraries and frameworks", as "writing programs the either way you did in procedural programming" and so forth. That the most confusing thing for me. I believe that main idea here is just about initiating any actions. Either you do something "whenever you want" (Procedural way), or you "wait" until someone asks you (IoC way). My Definition is: **IoC is a property of your program's execution flow, when you don't do anything until _they_ ask you to do it**. It sounds exactly as "Hollywood Principle", but I believe that "Hollywood Principle" and IoC are both absolutely the same idea. Do I understand it?


How to figure out design pattern for this particular solution?

While working on a project I've come up with some design solution. I am having a hard time relating it to any general design pattern or analyzing this situation in details. This is also prohibiting me to find any better design for this. This is a simple analogy of my solution - Both `Kangaroo` and `Tiger` can `walk` but only `Kangaroo` can `jump` and only `Tiger` can `run`.               Animal<TLeg> where TLegs: ILegs     {         TLegs Legs;         void Walk(){ Legs.Walk(); }     }          Kangaroo: Animal<IJumpingLegs>     {         void Jump() { Legs.Jump(); }     }          Tiger: Animal<IRunningLegs>     {         void Run() { Legs.Run(); }     }          ILegs     {        void Walk();     }          IRunningLegs : ILegs     {        void Run();     }          IJumpingLegs : Ilegs     {        void Jump();     }      [Edit]   Problem Description:   Here, Kangaroo and Tiger share common functions and a property Legs. Therefore, I have a base class for common functions. Base class needs to have access to this property `Legs`.   Functions in subclasses too rely on Legs and based on type of Legs, subclass will need to call different functions of this property. Basically, two concrete animals need some common methods and their uncommon methods(Jump and Run) require different TYPE of a common property. For this problem, I have come up with the solution described above. Hoping that I am able to describe my problem, I would like to know if there could be any alternate solution. Does this problem/solution sound familiar? Is there anything that can be improved?


How big can the binary code be?

Where does binary go in a computer? When you turn the computer on it points to the bios and runs through it. I get that. Then it loads data off something ( disk, flash, etc. ). But where does it go? Does the binary go in ram? Does that mean if my program is 2mb and ram is 32mb I can only address 30mb? I mainly want to know so I can tell how big my bin can be. I'm just a little confused on this issue. I know it's platform specific. But in general where would it go, and in general what document would I look at to check this information?