I am not a good programmer (in logic), how should I fix it?

Ok, so here is my problem: I work for a big company, some how landed a job (frankly because the interview was easy). It's not that I don't know my stuff, I am pretty good at understanding java, it's libraries etc. But, when ever I try to solve some logic problem, I find it really hard to come up with a solution. For example, `conversion of decimal to roman`, when I saw the solution, I find that it's a simple problem. _But I was not able to implement it after 1-2hrs of trying out!_ I feel I am dumb and not worth being a software engineer. Puzzle solving abilities should come natively to a great programer. But when I try to solve some puzzles, I am not able to find a solution and I just google it up!....and I hate that! When given a problem (like implement xyz feature) at work, I am fairly pretty quick at it and am respect at my work place for that, but I am not at all proud about it. Because when I try to solve any mathematically or logic wise challenging problem, I fumble. I still feel I love what I am doing (as an engineer) but feel really sad that I am not able to solve some tough logic problems which I friends come up with. I feel demoralized :( > TL;DR: I understand stuff from a practical viewpoint (implementing features > in our product) but when trying to work on problem from say ProjectEuler, I > SUCK badly! And I need to _Sharpen_ my brain! So, my questions are:   1. How should I go about fixing it? Should I start with solving (and forcing my self to) project euler problems? _Even if it takes hours for me to solve some basic problems_?    2. Or should I go back to basics and study some basic math?   3. I don't really find puzzle solving fun. But I want to make it fun for my self! And I think if I understand them in a better manner, I will like it! PS: I was never educated in CS (my undergrad was electrial). But that's not an excuse to be a sucky developer. Thanks!


Is it a good idea to collect anonymous usage statistics in a free program?

I'm the main author of a multiplatform free software/open source GUI program. Although the program gets thousands of direct downloads per month, I have no idea of the number of people regularly using it. It is also included in some Unix distributions and download sites making the counting harder. It would be interesting for me to know   * How many people use it? Should I bother continuing development?   * Which features of the program (dialogs, import filters, etc) do people most use? This would focus development. I'm considering some form of anonymous feedback (with the user opting-in), where the program sends monthly reports of the time since installation (whole months), the number of times each dialog is used, number of files opened, the version number and platform. The user would be asked the first time this is sent and there would be an option to disable it. I think I would only do this after the first week of usage, to exclude one-off users. Is doing this a good and ethical idea? I'm in the EU, so it's possible that data protection laws may apply.


What if I forgot to include someone elses copyright info in old commit?

Assume I have a public source code repository. Am I violating copyright laws if there's any old commit where I have not yet added all copyright info for _other_ people's open source code? Details: Consider this theoretical scenario:   1. I copy-paste _someone else's_ open source code files into a repository.   2. I commit.   3. I prefix copyright and licensing info at the top of the above-mentioned files.   4. I commit.   5. Many months passes, many people fork various versions of the master branch. Now, many months later, I realize that there are files in commit no. 1 with no copyright info. Do I have to squash the two above-mentioned commits, and rebase the whole repository? (Although it's been published! Everyone would be annoyed?) Or does it suffice that the current repo version provides all needed copyright info? Rephrased, for Git: If the HEAD of all Git branches, and all "published" Git tags, contain all required copyright and licensing info, do you think that suffice? And it'd be other people's responsibilities if they check out other commits and redistribute? Or am I the culprit, and will be thrown in prison?


Skeptic in a Scrum Team

My company has recently switched to an Agile way of working and as a part of it we've started using SCRUM. While I'm very comfortable with it and feel that this way is superior to a traditional one, some of my teammates don't share the same opinion. In fact they are very skeptical about "all that agile stuff", and don't take it seriously. As an example, one of the teammates is always late on the meetings, and doesn't really care about it. The management IMO tries not to notice this (maybe because it's new, and it takes time for the people to get used to it). My question is, how to address this issue while not raising a conflict inside the team?


DDD and filtering

I am developing an app in ddd maner. So I have a complex domain model. Suppose I have a Fare object and Airline. Each Airline should contain several or much more Fares. My UI should represent Model (only small part of complex model) as a list of Airline, when the user select the Airline, I must show the list of Fares. User can filtering the Fares (by travel time, cost, etc.). What is the appropriate place for filtering Fares and Airlines? I am assuming that I should do it in ViewModel. Like: My domain model has wrapped with Service Layer -> UI works with ViewModel -> ViewModel obtain data from Service Layer filtering it and create DTO objects for UI. Or I'm wrong?


How does a competition like Rails Rumble Work?

I am not sure weather it is a proper question to ask out here but it is really bothering for a while. As the official website writes: > The Rails Rumble is a distributed programming competition where teams of one > to four people, from all over the world, have 48 hours to build an > innovative web application, with Ruby on Rails or another Rack-based Ruby > web framework. After the 48 hours are up, a panel of expert judges will pick > the top ten winners. One thing I don't get is how judges make sure that the app was made in the given time constraint. The quality of apps is so magnificent that I am really skeptical that such elegant apps could be made within 48hrs, even if you have planned it straight out on paper.


Closest to “Mathematica Graphics[]" drawing environment for Python

Being only familiar with Mathematica and its Graphics, I have now to learn to draw Graphics using Python for a server. Mostly conditional combination of simple shape. **What would be a package for Python that make drawing Graphics as close as possible as the Mathematica Graphics environment ?** For Example, I would need to do such thing as in : http://mathematica.stackexchange.com/questions/1010/2d-gaussian-distribution- of-squares-coordinates#comment2475_1010


How can I provide a limited warranty for a software product?

Software, unlike most physical products you can buy, is sold with as few warranties as the vendor can get away with. As a developer, this seems very reasonable considering the quality of almost all software I've ever used - Think anything from unintuitive idioms, via undocumented features, irreproducibility, missing handling of concurrency, double escaping of user input, and floating point numbers where decimals would avoid long-term build- up of errors, to plain crashing bugs where the production database is corrupted and the equivalent of several hirings in the affected company are wasted on recovery and reactionary implementation of safety measures. It's a bit like building skyscrapers out of straw and nitroglycerin, hoping it will survive until the time when it's someone else's problem or it's replaced entirely. In such a situation, I hypothesize that a company which trusts their software enough to provide even minor warranties for damages incurred would (if their software was up to the task) gain an enormous advantage in _user trust_ , and could put Google, Microsoft and Apple to shame for quality software and hoarding of money and talent. I'm not familiar with the current status of software verification and requirements gathering research, so I don't know whether this possibility is just around the corner or whether we are hacking at the mountain with toothpicks. Certainly the existence of any serious company or organization at all providing such warranties or even working on guidelines for warranties would be extremely interesting to follow, as both a developer and user. Therefore: Are there any **international guidelines** for providing software warranties? Examples:   * If all the tests succeed, as long as the system stays in a defined state, the warranty covers the cost of recovery in case of data loss.   * As long as [some widely recognized set of security guidelines] are followed, the data handled by the system will not be readable by third parties. The warranty could cover anything from the price of the software to the legal costs of handling privacy-related lawsuits or more.


OCR - starting point

I really am a starter with OCR, and would like to implement an OCR system. Any pointers on where I can find the introductory material, with the programming kept in mind, like what algorithms or data representation models do I need to master? I found Tesseract, on Google Code, an open-source project, but before I dive in to the code, I'd like to have the concepts under my belt. thanks in advance, Yati


Randomness of wrapped RNG

_There are plenty of questions around regarding random number generation, but I couldn't find anything that exactly matched my question. Apologies if I missed one._ Most random number generators in software tend to have flat distribution - in the given range, any number is as likely to come next as any other (more or less). This is obviously the intention, because anything other than a flat distribution isn't entirely random because some numbers are more likely than others. However, there are times when a flat distribution is not desirable. For example, when building a game, it is often necessary to model real-world scenarios, many of which have a normal (bell-curve) distribution. If a "good" PRNG (such as an existing RNG from a popular programming language's main library) is fed into a simple equation, such as the equation for a bell curve, or a sine wave, or some other distribution, how far can we assume that the resulting PRNG is also "good"? Most of the tests for PRNGs test whether the system is purely random, so they won't work on this system. Is it just a matter of counting outputs over a long time and seeing how well they fit the desired distribution, or is there a simpler (eg. analytical or algebraic) way to check this? Any help would be appreciated.


What's the difference between implementing an Interface explicitly or implicitly?

In Visual Studio I can right-click on an interface and choose to Implement Interface, or Implement Interface Explicitly. ![Visual Studio Screenshot](http://i.stack.imgur.com/x4Rx6.png)               public class Test : ITest     {         public string Id // Generated by Implement Interface         {             get { throw new NotImplementedException(); }         }              string ITest.Id // Generated by Implement Interface Explicitly         {             get { throw new NotImplementedException(); }         }     }      The only difference I see between the two is that the Interface name is added to the interface properties and methods when they're created if you choose to Implement Interface Explicitly. I find it makes the code a bit more readable since I can see where that method/property comes from, however does this make any difference in how the class is used or compiled? And does it really matter if I implement my interfaces implicitly or explicitly?


Is coupling with strings "looser" than with class methods?

I'm starting a school group project in Java, using Swing. It's a straightforward GUI on Database desktop app. The professor gave us the code from last year's project so we could see how he does things. My initial impression is that the code is far more complicated than it ought to be, but I imagine programmers often think this when looking at code they didn't just write. I'm hoping to find reasons why his system is good or bad. (I asked the professor and he said I'd see later on why it's better, which doesn't satisfy me.) Basically, to avoid any coupling between his persistable objects, models (business logic), and views, everything is done with strings. The persistable objects that get stored in the database are hashtables of strings, and the models and views "subscribe" to each other, providing string keys for the "events" they subscribe to. When an event is triggered, the view or model sends a string to all of its subscribers who decide what to do for that event. For instance, in one of the views action listener methods (I believe this just sets the bicycleMakeField on the persistable object):                   else if(evt.getSource() == bicycleMakeField)         {             myRegistry.updateSubscribers("BicycleMake", bicycleMakeField.getText());         }      That call eventually gets to this method in the Vehicle model:               public void stateChangeRequest(String key, Object value) {                      ... bunch of else ifs ...              else         if (key.equals("BicycleMake") == true)         {                     ... do stuff ...      The professor says that this way of doing stuff is more extensible and maintainable than having the view simply call a method on a business logic object. He says there is no coupling between the views and models because they don't know of each others' existence. I think this is a worse kind of coupling, because the view and model have to use the same strings in order to work. If you remove a view or model, or make a typo in a string, you get no compile errors. It also makes the code a whole lot longer than I think it needs to be. I want to discuss this with him, but he uses his industry experience to counter any argument that I, the inexperienced student, might make. Is there some advantage to his approach that I'm missing? * * * To clarify, I want to compare the above approach, with having the view be obviously coupled to the model. For instance, you could pass the vehicle model object to the view, and then to change the "make" of the vehicle, do this:               vehicle.make = bicycleMakeField.getText();      This would reduce 15 lines of code that are currently ONLY used to set the make of the vehicle in one place, to a single readable line of code. (And since this kind of operation is done hundreds of times throughout the app, I think it would be a big win for readability as well as safety.) * * * **Update** My team leader and I restructured the framework the way we wanted to do it using static typing, informed the professor, and ended up giving him a demo. He's generous enough to let us use our framework as long as we don't ask him for help, and if we can keep the rest of our team up to speed -- which seems fair to us.


Study a project to be able to maintain it in future

I've joined as a fresher (trainee) a software company developing for Windows Store. I don't know much about C#. My company has started Windows Store development recently. They didn't do .Net development before, that's why my company got an Senior .Net employee to complete the project. Whenever he completes the project he will leave the company. I will have to maintain the project after him. So I need to study the project flow and analyze the project to be able to maintain errors in future. Can you suggest how to start to analyze the project and what to pay attention on?


What are some good ways for an employer to support developer education?

My current employer pays for certification fees and college classes (provided that you earn an 'A'), but I'm looking for other things to suggest to them. Very few of us have time to take advantage of the college classes, and the material covered in certification exams isn't always the most practical information. (Code Access Security, anyone?) Maybe a book allowance? Some incentive to work on an open source project? In what kinds of creative ways does your employer provide for your continuing developer education? ### See Also > How to Keep Your Developer Team Educated


Should I be paid for time spent learning a framework?

To give light to the situation: I am currently one of two programmers working in a small startup software company. Part of my job requires me to learn a Web development framework that I am not currently familiar with. I get paid by the hour. So the question is: Is it wholly ethical to spend multiple hours of the day reading through documentation and tutorials and be paid for this time where I am not actively developing for our product? Or should the bulk of this learning be done at home, or otherwise off hours, to allow for more full-on development of our application during the work day?


Moving from TFS to Distributed SCM

I am currently playing with the idea of pitching DSCM to management in my company. We currently use the full vertical TFS stack (SCM, Bug Tracking, Project Management etc.) - however I want to specifically target the source control (as I don't think retraining QA with something like Redmine would be achievable). Probably the biggest issue here is re-training a very large amount of developers to use the new SCM (and this includes the distributed train of thought) - which is probably not feasible at all. There needs to be some form of skills migration with the new system: this is where GIT fails horribly, as that would take months to catch on (and we are not a little startup shop - this is a very large company with real commitments). The next issue is the fact that we currently require check-ins to be associated with a real bug or task (work item) - I doubt management would bite if we couldn't control this. Ideally the developer machines should be zero- configuration, i.e. it should prevent 'illegal' pushes even if you just have the bare-bones SCM client installed. Being able to update TFS work items would also be a big plus - even if I had to write custom code, but once again this should be controlled by the central repository and not on developer machines. I know that in the long run DSCM alleviates many of the problems that we are facing day-to-day, but we can't afford the time of developers having merge issues or such. For example, my first GIT merge took me a good 2 days to figure out, because I was so used to the TFS mindset. This isn't acceptable when real deadlines are taken into consideration. Tooling is a big concern: it's incredibly easy to push in a merge marked-up file directly back into source control; which would result in a build failure - TFS doesn't allow you to do anything silly like this. Finally, having 'nice things' to show would probably help the pitch. We have a review process, showing off GitHub FI Commit Comments would be a strong example of why this stuff could be better - however, as stated, GIT is probably really the wrong route to go. **TLDR;** I have found most DSCMs to be tools and not frameworks (e.g. GIT is designed to be this); allowing you to easily shoot yourself in the foot - TFS is a framework and that is something valuable in the company. Has anyone ever tackled these types of issues when migrating to DSCM? What DSCM platforms did you use? What challenges did you face? Do you have any ideas on how this process could be streamlined and almost made painless?


General checklist before releasing software

I'm currently building a tool that my company intends to sell. I'm the sole developer on the project and it is being developed outside our normal code base and to a certain extent outside our normal process. I'm trying to put together a checklist of items to check before I deem the software ready to release for testing. These are the items that I've come up with so far:   * Is code commented appropriately?   * Does the code adhere to the defined Company Standards?   * Is there error handling in place?   * Is there appropriate security?   * Is there appropriate logging?   * Is localisation required?   * Have release notes and any accompanying documentation been produced?   * Has all testing and debugging code been removed?   * Has sensitive data been such as passwords and licence keys been removed?   * Has performance been checked? Any memory leaks? Can anybody suggest items that could be added to this list and explain why you would think it would be useful? My goal is to have a template checklist that I can then customise on a project by project basis.


Fast compression in C++ and decompression in C#

### Overview I am working on a client-server application. The client is written in C++ (working on Windows, planning to support Linux) and the server is a .NET RESTful service. I need to HTTP POST some data to the server. The data is a unicode `string` that I need to compress using any fast compression algorithm (needs to be light on CPU). On the server I need to decompress raw bytes and get a string. ### Problem I cannot decompress raw bytes and I end up with decompressor's output buffers stay intact. ### I tried I have tried using Google Snappy, there is only a C/C++ version and any .NET ports don't appear to be finished. I also checked LZ4, where compression/decompression works in a _single_ language, but when I try to use _both_ \- I cannot decompress data correctly (the decompressed bytes are set to 0s). ### Question Has anyone tried using a fast C/C++ compression and C# decompression? Any recommendations? Client application shall not use more than 5% of CPU - that's a vague requirement I have. I plan to try gzip and maybe deflate, but I am not sure if I can configure compression levels there or whether it will work in both C/C++ and C#. Client collects some near real time data into a small buffer, when that buffer gets full it shall be compressed and POSTed. The whole OS process shall take less than 5% of the machine's CPU. A buffer is roughly posted 2 times a second which creates a traffic of about 2Kb/sec.


Why does Scala use the '_' operator for package import instead of '*' as in Java?

In my opinion, one of the greatest things about Scala is its interoperability with Java and its similar syntax. One thing that I found strange is the use of the `_` operator for package wilcard imports instead of the `*` operator that is used in Java. Is there a technical reason for using `_` instead of `*`? If not, then why was this change done?


How the Compatibility View in IE works behind the scenes

When I remote connect to my work PC, in IE10, the juniper remote client service which is basically a plugin executed in the browser does not run. I need to turn on compatibility view to see it. My question is what exactly is happening behind the scenes in compatibility view such that such a large number of compatibility problems can be fixed with it? What did they do...make a list of deprecated APIs that was running ok in ie8 but deprecated in ie10 and then on clicking compatibility view, those APIs are supported again?


Unit test and Code Coverage of Ant build scripts

In our development environment We have more and more build scripts for ant to perform the build tasks for several different build jobs. These build scripts sometimes become large and do a lot of things and basically is source code in and of itself. So in a "TDD-world" we should have unit tests and coverage reports for the source code. I found AntUnit and BuildFileTest.java for doing unit tests. But it would also be interesting to know the code coverage of those unit tests. I have been searching google, but have not found anything. Does anyone know of a code coverage tool for Ant build scripts?


Java class to enforce an implementation of super classes' public methods

I have the following :               public Class A {              public void methodA() {             ....         }              public void methodB() {             ....         }          }      I don't have control over Class A. I would like to create subclasses of Class A with a restriction that it must override methodA() (super.methodA() call must run the implementation of Class A). is it possible? is so, how?


MATLAB: Best fitness vs mean fitness, initial range

1. Based on the example of Rastrigin's function. At the plot function, if I chose 'best fitness', on the same graph 'mean fitness' will also be plotted. I understand well about 'best fitness' whereby it plots the best function value in each generation versus iteration number. It will reach value zero after some times. I don't understand about 'mean fitness'in the graph plotted. What do those 'mean fitness' values mean? How does the 'mean fitness' graph help to understand Rastrigin's function?   2. What are the meaning of the term initial population, initial score and initial range? I wish to have a better understanding of these terms.   3. The default value for initial range is `[0,1]`. Does it mean that `0` is the lower bound (`lb`) and `1` is the upper bound (`ub`)? Do these values interfere with the `lb` and `ub` values I set in the constraints?   4. I try to better understand about `lb` and `ub`. If my `lb` is `0` and `ub` is `5`, does it mean that my final point values will be within 0 and 5?   5. If I know the `lb` and `ub` for my problem is between `0` and `5`, do I just set the initial range as `[0,5]` at all times and may I assume that this is the best option for initial range, and I need not try it with any other values?


Will C# merge with native C++ compiler?

According to this post : http://channel9.msdn.com/Forums/Coffeehouse/MS-working-on-a-same-compiler-for- C-AND-C--Not-in-incubation-but-for-production- How much truth is in this post? Should it be taken seriously by hardcore C++ programmers (game devs etc)?? Edit : There's another purpose to this question... Will C# be backward compatible with C++?


Should I make up my own HTTP status codes? (a la Twitter 420: Enhance Your Calm)

I'm currently implementing an HTTP API, my first ever. I've been spending a lot of time looking at the Wikipedia page for HTTP status codes, because I'm determined to implement the right codes for the right situations. Listed on that page is a code with number 420, which is a custom code that Twitter used to use for rate limiting. There is already a code for rate limiting, though. It's 429. This led me to wonder why they would set a custom one, when there is already a use case. Is that just being cute? And if so, then which circumstances would make it acceptable to return a different status code, and what, if any problems may clients have with it? I read somewhere that Mozilla doesn't implement the joke `418: I’m a teapot` response, which makes me think that clients choose which status codes they implement. If that's true, then I can imagine Twitter's funny little enhance your calm code being problematic. Unless I'm mistaken, and we can appropriate any code number to mean whatever we like, and that only convention dictates that 404 means not found, and 429 means take it easy.


Automation Testers vs Developers

What are the differences between automation testers and developers?


Do threads delete themselves?

Let's say I was working on a Swing application. Most of it is run on the EDT using `SwingUtilities.invokeLater()` inside the `main` method, because I heard (please correct me if I'm wrong) that that's what you need to do with Swing. However, some parts of it shouldn't run on the EDT. These parts are parts that take long to complete (I assume that this is because long tasks on the EDT will interfere with GUI stuff the EDT should be doing, and thus these kinds of tasks should be run on parallel, on a different thread. Is this assumption correct?) To do this, when I need to perform a task that takes long to complete and thus can't be run on the EDT like the rest of the program, I create a new thread and run that task inside it. **My question is:** When the `run()` method of that new thread finishes, aka the thread finished it's job. Does it delete itself? Or does it keep existing in the memory?


Is curl something that's not expected to be installed on servers? I'm working for a small development shop and 99% of the problems that I'm having is regarding curl. Most of the projects that I'm working on involves calling a web API. Most web API's suggests using curl by default since you have to pass in a POST data in the request. Every time I complain to my senior that the server that I'm working on doesn't have curl installed the excuse that I'm always getting is that curl is not needed you can always use `file_get_contents`. So the question: is curl something that's not expected to be installed on servers that runs PHP, should I always develop using `file_get_contents` and not curl? Are there any advantages of using `file_get_contents` over curl or vise versa? If it helps, the context here is wordpress plugins, shopify apps, drupal modules and other bits of code that a lot of people can install.


Design and relationship of a cursor and its referred object

I need to implement a Cursor class to perform operations on a Document object, which is implemented internally as a simple list of rows. The Cursor class must have methods such as moving around the Document, add lines, remove lines, insert text in a given position etc. The problem I have is relative to the details of the design. To me, it seems that the cursor _must_ know the implementation details of the referred class. In C++, these classes must be friend classes, but I don't like it for obvious reasons (encapsulation etc.). I can't envision an interface for the Document class to keep its implementation private that also doesn't defeat the purpose of a Cursor class, that is, I end up having the interface of the Cursor on the Document class itself. Is leaking Document implementation details mandatory when implementing a Cursor? If not, what should the Document interface be?


Is documentation a User Story?

We need to do some user documentation for a product we have been working on for the past few sprints. We are now starting a new project in the next sprint and the PO is making the documentation for the product produced previously a User story for this sprint. I am just wondering your opinion on this approach. Personally, I don't agree that documentation is a User Story within Scrum because it doesn't produce any code. EDIT: Thanks for your opinions guys. I had it in the back of my head that a sprint was to implement an increment of working software, but your views have changed my outlook. Thank you for all your answers.


How do you estimate the time required for a "research phase" in agile development?

In the context of agile development, what is the appropriate amount of learning that an engineer should engage in before implementing a solution to a problem? If an engineer knows she is too ignorant of a given topic (say, compression) to start implementing, she goes and learns what she thinks she _needs_ to know, and then implements a solution. Clearly a deeper understanding of said topic _could_ result in a better implementation, but at the cost of agility. On the flip side if an engineer learns too little about a topic, there is a danger she will implement a significantly insufficient / broken implementation that negatively affects customers in the immediate or near future. Towards which end of this scale, if any, do guiding principles of agile lead an engineer? Or does agile leave this as a sliding scale, where the answer may be different in any given situation? ### Update: To be clear, I'm asking specifically what agile has to say, not what you think the right amount of learning should be. The former has a specific answer, the latter is subjective and not appropriate for Programmers ### Update 2: I rephrased the question title as a question, but my question remains the same (note the lack of change anywhere but this section and the title). Most of the answers, while insightful, did not answer the question (But they were appreciated! :) I'm looking to understand not when/how inside agile development research happens, but moreover how to estimate a "good" amount of time to spend learning a topic in the research phase before moving on to implementing a solution. I understand that in some cases, not a lot of research is required, and in some cases developers are faced with a topic even the senior-most developer knows little to nothing about, so the answer to this question includes an element of scalability to meet both situations.


Use the latest technology or use a mature technology as a developer?

I would like to develop an application for a group of people to use. I have decided to develop using python, but I am thinking of using python 2.X or python 3.X. If I use python 2.X, I need to upgrade it for the future... But it is more mature, and has many tools and libraries. If I develop using 3.X, I don't need to think of future integration, but currenttly it doesn't have many libraries, even a python to executable is not ready for all platforms. Also, one of the considerations is that it is a brand new application, so I don't have the history burden to maintain the old libraries. Any recommendation on this dilemma? More information about this application:   * Native application    * Time for maintenance: 5 years+    * Library/Tools must need: don't have idea, yet.   * Must need feature that in 2.X: Convert to an executable for both Windows and Mac OS X


Is it ok for services to reference one another?

I have a service that needs information implemented by another service in the same layer. Is it good practice for one service to take a dependency on another service in the same layer?


What negative consequences can arise from this language design rule?

_Clarification: the rule is meant to prevent accessing variables that are not declared yet._ _Clarification 2: the rule mandates that the compiler follows calls to functions which are defined in the same scope as the call and happen before the actual definition (forward referencing) - making the compiler much alike an interpreter._ I'm thinking about a fictional programming language that behaves similar to JavaScript when declaring functions: that is, when using the `function` keyword to create named functions, they get "hoisted" to the top of the scope and can be used anywhere where their name is visible. For example, the following is legal:               f();     function f() { console.log("f called") };      However, there is a potential problem: what if the function `f` uses a variable `x`, that is defined _after_ the call, like here:               f();     var x = 1;     function f() { console.log(x); }      In case of JavaScript, this is also legal, because variables are hoisted as well - the program gets essentially transformed into something like this:               var x;     function f() { console.log(x); }          f();     x = 1;      And therefore just prints `undefined`. **In my fictional language, variables wouldn't get hoisted** , which means that the example before would produce an error. The rule concerns how this error is generated: > Functions are visible for the entire block in which they are defined, but it > is illegal to call a function that accesses a variable declared after the > call. **This means that each time the compiler for this language would encounter a function call, it would have to check if the function is defined in the current scope, and if it is, check if it accesses variables in the current scope that are declared after the call.** The reason for this rule is that it makes no sense to access variables before they are declared. Hoisting the variables to the top of their scopes like JavaScript does is a hack that only leaves room for error! This is why I believe it must not be done, but such situations should be detected and treated as errors (because they are, you're referencing something that doesn't chronologically exist yet). **_I'm looking for reasons why this is a bad rule, i.e. results in complications or inconsistencies._** The reason I suspect that the rule is a bad one is that it does not exist in the Scala language. Scala solved this problem with a much more general rule: > The scope of a name introduced by a declaration or definition is the whole > statement sequence containing the binding. However, there is a restriction > on forward references in blocks: In a statement sequence `s[1]...s[n]` > making up a block, if a simple name in `s[i]` refers to an entity defined by > `s[j]` where `j >= i`, then for all `s[k]` between and including `s[i]` and > `s[j]`, > >   * `s[k]` cannot be a variable definition. >   * If `s[k]` is a value definition, it must be `lazy`. > **UPDATE:** For the time being I have adopted Scala's approach. This approach is a more general version of my rule: it will catch all illegal accesses, but also some that are not - this is a tradeoff that I'm willing to make since I think that my rule may be too complicated or even impossible to implement. Here's the rephrased/explained rule from Scala: Variables cannot be forward-referenced, but lazy values, functions defined with def (which are just syntax sugar for lambdas assigned to (lazy) values, might even remove them as Doval suggested), classes, and modules can. The restriction is that between the reference and the declaration (inclusive), there must be no variable definitions, because they might be altered by the entity being referenced before they are introduced to the program.


Convert to Object Oriented Programming

I am currently working on a project that is fairly small for the time being. There was a recent change to implement 3-tier architecture, such that the code is now split up appropriately to data access, business logic and user interface tiers. However, there is no use of objects outside of creating them to ultimately call a data access method. At a very basic level, pretty much everything we do is:                   Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load             Dim dt As New DataTable             dt = objBl.GetSomething             'Assign to Grid             'Format Grid         End Sub      I want to implement something more like:               Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load         Dim lstSomeObject As New List(Of SomeObject)         'Populate list of objects by calls to business layer         DataGridView1.DataSource = lstSomeObject         'Format Grid     End Sub      Ultimately, not much different. But instead of us having to pass thirty variables through to get a resultant data table that is used once, we could create an object (and lists of objects) and pass these around instead. I have a couple years experience working in such an environment, but zero experience in converting to such an environment. Frankly, I am at a loss as to how to do this. Do I create a separate entities project for this, and then does everything reference this? Or do I force our current objects to store both the properites and methods for each object type (this way feels counter-intuitive to me)? Or something else entirely? I have searched around most of the weekend and have not found anything overly helpful.


Exceptions: Why throw early, why catch late?

There are many well-known best practices about exception handling in isolation. I also know the do and don'ts very well, but I search for a best practices or patterns in larger environments, especially when to rethrow and when to catch exceptions. Moreover I'm always confused if I read: "throw early, catch late". Why should I throw early and catch late, if at a low-level-Layer a NPE is thrown? And why should I catch it at a higher layer? It doesn't make sense for me to catch a low-level exception at a higher level, like business layer. It violates concerns of each layer. Imagine the following situation: I have a service which calculates a figure. To calculate the figure the service accesses a repository to get raw data and some other services to prepare calculation. If something went wrong at the data retrieval layer, why should I throw a DataRetrievalException to higher level? In contrast I would prefer to wrap the exception into a meaningful exception. ### Why throw early, why catch late?


What exactly is Virtual Machine Bytecode?

I want to work on a very simple compiler for a very simple language. The compiler will compile the code to some basic bytecode. Later, a virtual machine program will run the bytecode, and execute the program. I have several questions about what bytecode actually is:   * Does bytecode have to be of binary form, aka composed of only 1 and 0 sequences? Or can it include more kinds of numbers, and even words?   * **How exactly, most commonly, is the bytecode of a program composed?** One idea I had for what the bytecode will contain and how it will be composed, using my compiler, is: The compiler will scan the developer's code, and convert each command to some bytecode equivalent. For example, the command `print` will be converted to `1` in the bytecode. Later, when the VM runs the bytecode, each element in the bytecode will be converted to some execution in the program. For example, if the VM scans the bytecode and comes acorss `1`, it will print something. Is this approach common? Is it valid? What is the most common approach to how and what the bytecode composes?


CQRS and cache invalidation (while load balancing)

I'm slowly trying to migrate our web application to use CQRS principals. In particular, I have separated "write" and "read" interfaces into commands and queries. I have implemented a "reader" class that can read some data from the DB. I have also implemented a decorator for this reader that caches the data to avoid any unnecessary roundtrips to the DB. At the moment this decorator is caching per-request. I'd like to cache this data for a longer duration - eg for a sliding 5 minute window. However, the problem is that a command that updates the data should invalidate the cache once the write occurs, and I'd like to capture that notion explicitly in our domain model. Specifically, here is the "read" interface (c#):               public interface IRoleLister     {         IList<DomainRole> Fetch(OtuIdentity otuIdentity);         IList<DomainRole> FetchForAuthenticatedId(int userId);     }      And here is the write interface:               public interface ICanChangeDomainRoles     {         void AddRoleToUser(int userId, DomainRole domainRole);         void RemoveRoleFromUser(int userId, DomainRole domainRole);     }      I realize that some variant of the observer pattern would probably be applicable, but I'm not sure how to capture that in the domain model. I also have identified another problem - namely cache key naming. In the IRoleLister I want to cache IList<DomainRole> by user (eg typeof(IList<DomainRole>) + ":userid" as the key) but in ICanChangeDomainRoles I don't know the key name. My thoughts are that the Observer should in someway be responsible for this. (Or perhaps some other interface? How do I capture that concept in my domain). Finally, I realize that some form of distributed cache would help, but that seems like an implementation detail - I want to capture the invalidation/notification/observer concept in my domain model. Any pointers would be appreciated


what is message passing in OO?

I've been studying OO programming, primarily in C++, C# and Java. I thought I had a good grasp on it with my understanding of encapsulation, inheritance and polymorphism (as well as reading a lot of questions on this site). One thing that seems to popup up here and there is the concept of "message passing". Apparently, this is something that is not used whilst OO programming in today's mainstream languages, but is supported by Smalltalk. My questions are:   * What is message passing? (Can someone give a practical example?)   * Is there any support for this "message passing" in C++, C# or Java?


Visualizing a CUP grammar

I am implementing a grammar in CUP, and it would often be helpful to see everything at a glance. This could also be useful in finding errors quickly. Are there any programs out there that will visualize grammar in the CUP syntax? Or can you think of a very easy way of doing it (for instance, convert the grammar to another format that program X can read).


Shared Cache - Invalidation Best Practice

I'd like to know what would be a better approach to invalidate/update cache objects. **Prerequisites**     * Having remote memcached server (serving as cache for multiple applications)   * All servers are hosted by azure (affinity regions, same data centers)   * Cache object size ranges from 200 bytes up to a 50 kilobytes     **Approach 1 (store in cache asap)**     1. Object A is created -> store in database and store in cache   2. Object A requested by client -> check cache for existence, otherwise fetch from database and store in cache   3. Object A gets updated -> store in database, store in cache Approach 1 seems to be more straightforward. If something is created, put in the cache asap. Regardless of someone will need it.    **Approach 2 (lazy cache store)**     1. Object A is created -> store in database   2. Object A requested by client -> check cache for existence, otherwise fetch from database and store in cache   3. Object A gets updated -> store in database, delete key in cache Approach 2 seems to be more memory-aware. In this approach only requested items go to cache.    **Question 1:** In mind of performance, what would be a better approach? Memory nor CPU do not count yet.      **Question 2:** Are my thoughts a kind of premature optimization?      **Question 3:** Any other thoughts? Other approaches?


Ordered enumeration: IEnumerable or Array (in C#)?

Typical context: I make an extension method for a collection which considers that the elements are ordered. The function starts at the beginning, at index 0, and the order has significance. Examples: Grouping by sequence or Indexes of an item. However, I'm always stumped as to what to extend: `IEnumerable<T>` or `T[]`. My rationale was clarity of purpose: An array has a notion of ordering, whereas an IEnumerable is implemented by many generic collections, not all of which have a notion of order:   * Dictionary - unordered   * HashSet - unordered   * LinkedList - ordered   * List - ordered   * Queue - ordered   * SortedDictionary - sorted (not original order)   * SortedList - sorted (not original order)   * SortedSet - sorted (not original order)   * Stack - reversed As well as any other implementation which might or might not be ordered. Also, I'm not certain if the enumerator is reset if an enumeration is not completed, so if that's a worry, then who knows at what point the enumeration would start? Enumerating an array would always start at the beginning. So to me, it makes more sense to extend a `T[]`. But am I correct in thinking that? Am I worrying too much? What's the proper approach for ensuring "ordered" enumeration?


Algorithm for the shrinking of pixel art

This is something I've been wondering about for a while - are there any algorithms out there to scale pixel art down? I'm sure we all know about the upscale versions on the Wikipedia page on Image Scaling. I would have thought something like nearest neighbour resampling to get the colour pattern right, and then redrawing the outline, or high-contrast areas, over the top. Is there anything out there or am I going to have to learn how to do this myself? Thanks!


Getting started with build tools

I am on my final year on CS, working on my first significant project, so I thought its about time to learn and use build tools. I have read about Maven mainly and heard about Ant. I would like to know your opinion about which I should learn to use for a project that will be developed only by one person, keeping in mind the learning curve, and the functionality that will be useful in this case.


Why do projects opt to stay on an older version of the .NET Framework?

Why do projects opt to stay on an older framework version of the .NET Framework? For example, staying on .NET Framework version 3.5 which was released in 2007 instead of upgrading to the latest 4.5.1 version? Jon Skeet's Noda Time also targets .NET 3.5. Why?


when to load partial views

When creating a website, when should you load partial view and when should you do a complete page refresh? I was looking at github's site and noticed that pretty much the only place they do partial loading is in a project's folder area. I could see a couple places where they could have but didn't(tab navigation: feed, your actions, ...). But, Google plus does partial loads for search, and clicking on any of the header navigation buttons (pictures, games, circles, ...). Why would you not do partial loading if the main container stays the same and the content is the only thing that is changing?


Is there something like Diaspora written in PHP?

I am looking for an open source social networking platform. Diaspora is perfect, except it is not written in PHP. Is there a project like Diaspora written in PHP?


Software Development - Project, 1 Programmer - What if hit by bus?

The company I am currently working for has me developing a bunch of internal mission critical software. I have one other person that works for me but he's more of a testing guy and not really a developer. The company is concerned about some of these projects and what happens if I am hit by a bus. How does the company pick back up after something like that when there is only one person that knows the code base. One person that knows the current status of the project. I explained that with my documentation and with the documentation with in the code that they would really only need to hire another programmer that understands the languages that were used and that they could be up to speed pretty quickly. They suggested an outside firm that might be "kept up to date" on a monthly basis that could "take over" in the event something happened. I just don't see how this could be helpful beyond paying someone for the sake of paying them. Worse I envision a day a month being wasted discussing the project with this consulting firm. I see how this could be helpful I just don't see it as anymore helpful than hiring a programmer after my untimely demise. Thoughts? Similar situation and how its currently being handled where you work?


What are the business benefits of Ruby/Rails to tell a client?

I'm programming Ruby. I'm programming Rails. It's zen, it makes fun and it's cool. But what are the real technical and foremost business advantages of Rails, I can tell a client? I know the implementation details should be aligned on the requirements of a project. But if I'm honest, if someone says: "Hey, why not using a wordpress and a little bit customized template? It's much cheaper!", I don't have enough good arguments for Rails. Especially for smaller and mid-scale projects. So, what do you tell your clients, when you think they should use Ruby/Rails?


Why was Java chosen for Android?

Why was Java chosen for Android, instead of something like C++? While I certainly am no expert, I have heard that Java uses quite a lot of memory and I would presume that low memory usage would be quite important on mobile devices. Is there any real advantage to using Java instead of a language like C++ on a mobile device?


How do you avoid name similarities between your classes and the native ones?

I just ran into an "interesting problem", which I would like your opinion about: I am developing a system and for many reasons (meaning: abstraction, technology independence, etc) we create our own types for exchanging information. For instance: if there is a method which is called SendEmail and is invoked by the business logic, it way have a parameter of type OurCompany.EMailMessage, which is an object which is completely technology independent and contains only "business relevant data" (for instance, no information abut head encoding). Inside the SendEmail function, we get this information from our EMailMEssage object and create a MailMessage (this one is technolgy specific) object so it can be sent over the network. As you can already notice, our class has a very similar name to the "native" language class. The problem is: this is exactly what they are, email messages, so it is hard to find another meaningful name for them. Do you have this problem often? How do you manage it? Edit: @mgkrebbs just commented about using fully qualified names. This is our current approach, but a little bit too verbose, IMHO. I would like something cleaner, if possible.


History of Associative Array?

In quite a lot of modern scripting languages (e.g. Perl, Python, Ruby, PHP, Lua, JavaScript), associative arrays are supported as a primitive or first- class data type (with various names like map, dictionary, hash, etc.) in a very convenient syntax, making convenient data-driven paradigms possible. Which language first adopted such a design? And how has this design evolved?


Filling array with numbers from given range so that sum of adjacent numbers is square number

**Problem:** Fill all the cells using distinct numbers from <1,25> set, so that sum of two adjacent cells is a square number. ![enter image description here](http://i.stack.imgur.com/ejYiD.png) (source: http://grymat.im.pwr.wroc.pl/etap1/zad1etp1213.pdf; numbers 20 and 13 have been given) I've already solved this problem analytically and now I would like to approach it using an algorithm. **I would like to know how should I approach these kind of problems in general (not a solution, just a point for me to start).**


What is a thread pool?

In an interview question a guy was asked to "implement a threadpool"... I've been reading on wikipedia for "threadpool" but I still can't figure out what should a guy do to solve this question (possibly because I didn't quite understand what a threadpool is in simple terms). Can someone explain me in plain english what a threadpool is and how would one answer this question?


Good idea to move logic out of SQL statements?

I'll preface this question by saying that I am very new to professional software dev. I work on a team that takes data in from other groups in my company and turns this data into reports usable by business execs. In the process of transferring and parsing data we have some SQL statements that do a lot of processing of the data. Nearly every `SELECT` uses `TRIM`, `SUBSTR`, `CAST` etc extensively to reduce fields to the proper size and format. Additionally there are a lot of special cases that are accounted for by using `CASE` statements within `SELECT`'s. The Teradata server software that we use emits remarkably cryptic error messages. As a result we do a lot of guesswork about what data is breaking which SQL statement. **My question is:** would it be a good idea to reduce these somewhat complex SQL statements to a less complex form that omits the processing and special case handling, and instead do this work in an external script or program? Does this make any sense?


Is the number of bugs in a section of code proportional to the # of lines ? The square of the # of lines ?

Are there any studies that aggregate data over a wide population of contributed code, that establish a correlation between amount of code written in a commit and the # of bugs discovered in that code ? It'd be hard to do in github without knowing whether a change was due to new functionality or a bug, but you could determine a relation between lines of code per commit and how much thrashing eventually goes on in that code.


Is a CPU a computer?

I read that a computer is made up of the CPU and the memory. I also read that the CPU itself contains a cache which is memory. So if the CPU itself contains the memory, isn't the CPU a computer? Please clarify, thanks. EDIT: I read here: http://www.dwightsilverman.com/future.htm it says: > A processor is, itself, a computer, and they now are small enough that they > are embedded in everything from car engines to toasters. Although these > processors are relatively dumb, designed to do just one thing, smarter > processors that are more versatile also are finding their way into tiny > places.


What were the Design Patterns of the procedural programming era?

Similar: How was programming done 20 years ago? OOP is quite fashionable nowadays, having its roots in Simula 67 in the 1960s, and later made popular by Smalltalk and C++. We have DRY, SOLID, many books about design patterns in the object-oriented world. _But what were the main principles in programming prior to the OOP paradigm wide adoption? And what were the major design patterns?_


What is a good non-technical example of a cumulative error?

I'm working on a report which needs to explain in non-technical terms the effects of a cumulative error, and why it is of importance to use absolute calculations. Definition of 'cumulative error' from dictionary.com: > an error that gradually increases in degree or significance during a series > of measurements or calculations; an error that grows during observation Ideally I could give **a real world example** so they grasp the concept of it without knowing about the specifics. The first one I though of is 'Chinese whispers' which is pretty well known, but I wouldn't exactly classify it as 'real world'. Does anybody know of better examples?


Why do CSV file formats normally use quoting instead of escaping?

There are a lot of variants of the CSV "standard" (or lack thereof). I've never personally see any that use an escape character (like `\`) instead of surrounding each field with double quotes. Instead of `foo,bar,"foo,bar"` it would be `foo,bar,foo\,bar`. This would be handy for situations where a file needs to manually inspected or edited by hand. When counting commas to find the right field, it seems that it would be easier to tell which ones were not field separators if they escaped instead of quoted. I don't see how it would make a difference from a parsing perspective, though. Why quote instead of escape?


Full Text Indexing Strategy for MS Excel Documents

### Background As part of a broader application that allows users to search thousands of MS Office documents on a private network, I need to index and make searchable Microsoft Excel files. My basic approach for all document types is this:   1. Loop through the raw directories I have been given,   2. Upload the document to a network share   3. Extract some searchable text from content of the document.   4. Create a new MS SQL record with the name of the document, URL of it's location, and searchable content.   5. Use MS SQL's `Full Text` indexing on the "content" column so that end-users can search key words or phrases via a user interface. ### Problem/Question I am not sure of the most optimum approach for extracting searchable text from Excel docs. My initial thought is to loop through the doc: cell-by-cell and pull out all text and then concatenate that text together into the SQL record, but that seems to be a bad strategy as there could be several cells that are exact duplicates, cells that are only numeric, and generally other types of noise. Is there an established design pattern or strategy for case? Absent that, I welcome and appreciate any suggestions (as will future Stack Exchange users facing the same problem).


Is this the correct approach to an OOP design structure in php?

I'm converting a procedural based site to an OOP design to allow more easily manageable code in the future and so far have created the following structure:               /classes     /templates     index.php      With these classes:               ConnectDB     Games     System     User     User   -Moderator     User   -Administrator      In the index.php file I have code that detects if any `$_GET` values are posted to determine on which page content to build (it's early so there's only one example and no default):               function __autoload($className) {         require "classes/".strtolower($className).".class.php";     }          $db = new Connect;     $db->connect();          $user = new User();          if(isset($_GET['gameId']))     {                System::buildGame($gameId);     }      This then runs the BuildGame function in the system class which looks like the following and then uses gets in the Game Class to return values, such as `$game->getTitle()` in the template file `template/play.php`:               function buildGame($gameId){              $game = new Game($gameId);         $game->setRatio(900, 600);              require 'templates/play.php';     }      I also have .htaccess so that actual game page url works instead of passing the parameters to index.php Are there any major errors of how I'm setting this up or do I have the general idea of OOP correct?


Reconstructing a tree from depth information

I have a data structure that describes a tree. Nodes are ordered, with "depth" information, and knowing the order and the depth the tree can be reconstructed. I'm not entirely sure how to describe it so I'm hoping this small example will illustrate it               node #1, depth 0 // parent: none     node #2, depth 1 // parent: #1     node #3, depth 1 // parent: #1     node #4, depth 2 // parent: #3     node #5, depth 1 // parent: #1     node #6, depth 2 // parent: #5      (I added parent information in there for clarification. That's not part of the data structure.) I'm trying to write an algorithm (in JS, if that's any help) that will iterate over each node and build a tree out of the data. I'm fairly recursion is the way to go but beyond that I'm not sure where to start. Any suggestions? Edit: The way I see it, I have four cases:   1. Node has depth 0 (initial case)    2. Node has same depth as previous   3. Node has greater depth as previous (should only be previous.depth+1)   4. Node has less depth than previous Here's my pseudo-JS-code so far:               process (nodes, 0);     process = function(nodes, i) {       cur = nodes[i], prev = nodes[i-1]       if cur.depth = 0 then cur.parent = null  // case #1       else if cur.depth == prev.depth then cur.parent = prev.parent // case #2       else if cur.depth > prev.depth then cur.parent = prev // case #3       else // case #4... here's where I'm stuck.       if i <= nodes.length then process (nodes, i+1)     }


What is the difference/ advantage of doing double assignment?

Is there any advantage / is it a bad practice in Java to do the below               x = x = 5      I saw it in one of my peers code and I was surprised why he would do double assignment? Is this something that is same as `x = 5` or if `x = x= 5` makes a difference?


Overcome clumsiness in writing code

I believe this is a little related with this question: How to be a zero-bug programmer?. But I believe this is more regarding clumsiness in programming because I know it is impossible to become a zero bug programmer. Often, I write a very buggy code caused by my own clumsiness. For example in writing a currency rate conversion function, a trivial function. I can code the function that running well given the correct value. But sometime I just forgot to validate some unexpected-but-reasonable values. So are there any ways for clumsy programmer like me to write and test the code more thoroughly? **Additional** I see a lot of people suggesting to write unit test or using TDD approach. But writing unit-test not always goes well because of clumsiness isn't it? I don't because I once tried to write unit-test, but still often bumps with bugs.


What techniques should I use when implementing infinite scrolling on a website?

I am currently working on a website which implements infinite scrolling on it's search page (the results themselves coming from Elastic search) and, unsurprisingly, the more you scroll the slower things get. This is especially prominent on mobile devices, and in particular lower cost devices (which most people use). We have put a lot of work into making the site responsive on mobile devices from an HTML/CSS perspective, but inevitably as you add more items to the DOM, things slow down. I see that sites like Twitter and Facebook do a good job at avoiding this problem, but how? I am guessing it is some form of DOM garbage collection, and items are loaded not just as you scroll down, but up also, and items not in view are GC'd? Adding to the complexity, we are using the headroom.js library to have the menu needed to alter the search options always available by just scrolling up slightly, and we notice that this action gets slower and more jarred as you scroll down and have more search results to scroll through. Each search result consists of not just text, but an image also. Also, the search results are refreshed without a reload of the page, we use two way binding provided by AngularJS for this purpose (pushing search results into, and popping them out of an array which ng-repeat uses to populate the view), but I suspect that users of other libraries (such as Ember.js) face the same problem. Can somebody elaborate on how we should be approaching this? We have the infinite scrolling aspect (loading more items into the DOM as you scroll) nailed, but on lower end smart phones, things slow down quickly so I am guessing there another aspect to this problem which we have missed. I assume the trick is to only load items into the DOM that the user can see while keeping the scrollbar as is, and responding to scroll events to load the items the user was expecting to see, but how would we go about this? Are there any libraries available for this purpose? Thanks


Is there a recommended order to take the Oracle Java EE certification exams?

I recently passed the Oracle Certified Professional, Java SE 6 Programmer examination. Now, my boss would like me to take "the next step" to broaden my competence. I tried to explain that there is no equivalent Java EE 6 Programmer examination, but a number of different exams, such as Web Services, Web Components, and Enterprise JavaBeans. Is there a recommended path to follow for the various Oracle certifications in the Enterprise Edition of Java? Is it logical to take some exams prior to taking others because the content builds upon previous knowledge or are they all independent?


How many questions are appropriate to ask as an intern?

So, I just started an internship, and I'm worried that I'm asking too many questions. My mentor assigns me projects and helps me learn all the company's technologies and methodologies. However, there's so much new material for me to learn while doing this project that I have a lot of questions. I generally ask questions over instant messages or E-mail (those are the primary modes of communication for my company). I'm trying to be careful not to ask too many questions: I don't want to come off as annoying or dumb. How many questions are appropriate to ask? Once an hour? More? Less? Keep in mind, my mentor is also a fellow programmer who has his own responsibilities.


How Jetbrain Phpstorm IDE is working without installed java?

As far as I know Jetbrains PHPStorm is programmed in Java but while I don't have Java installed in my Windows 7 PC, PHPstorm is installed and working without any problem. How It's done?


Advantage of Solr over other DBs?

As far as I know, Apache Solr Lucene project is a web-app which is used for rich text searching. I just wanted to know:   * Why can't I use MySQL for that and just for rich text searching, why we use Solr?    * When all the other things can be performed using any DB ?


Functional or non-functional requirement?

I'm wondering about functional or non-functional requirements. I have found lot of different definitions for those terms and I can't assign some of my requirement to proper category. I'm wondering about requirements that aren't connected with some action or have some additional conditions, for example:   1. On the list of selected devices, device can be repeated.   2. Database must contain at least 100 items   3. Currency of some value must be in USD dollar.   4. Device must have a name and power consumption value in Watts. are those requirements functional or non-functional ?


REST API concepts

I have three questions about REST API design that I'm hoping someone can shed some light on. I've searched relentlessly for many hours but haven't found answers to my questions anywhere (maybe I just don't know what to search for?). **Question 1** My first question has to do with actions/RPC. I've been developing a REST API for a while and I'm used to thinking of things in terms of collections and resources. However, I've come across a couple cases where the paradigm doesn't seem to apply and I'm wondering if there is a way to reconcile this with the REST paradigm. Specifically, I have a case where modifying a resource causes an email to be generated. However, at a later point the user can specifically indicate that they want to resend the email that was sent earlier. When resending the email no resource is modified. No state is changed. It's simply an action that needs to occur. The action is tied to the specific resource type. Is it appropriate to mix some sort of action call with a resource URI (e.g. `/collection/123?action=resendEmail`)? Would it be better to specify the action and pass the resource id to it (e.g. `/collection/resendEmail?id=123`)? Is this the wrong way to be going about it? Traditionally (at least with HTTP) the action being performed is the request method (GET, POST, PUT, DELETE), but those don't really allow for custom actions with a resource. **Question 2** I use the querystring portion of the URL to filter the set of resources returned when querying a collection (e.g. `/collection?someField=someval`). Within my API controller I then determine what kind of comparison it is going to do with that field and value. I've found this really doesn't work. I need a way to allow the API user to specify the type of comparison they want to perform. The best idea I've come up with so far is to allow the API user to specify it as an appendage to the field name (e.g. `/collection?someField:gte=someval` \- to indicate that it should return resources where `someField` is greater than or equal to (>=) whatever `someval` is. Is this a good idea? A bad idea? If so, why? Is there a better way to allow the user to specify the type of comparison to perform with the given field and value? **Question 3** I often see URI's that look something like `/person/123/dogs` to get the `person`s `dogs`. I generally have avoided something like that because in the end I figure that by creating a URI like that you are actually just accessing a `dogs` collection filtered by a specific `person` ID. It would be equivalent to `/dogs?person=123`. Is there ever really a good reason for a REST URI to be more than two levels deep (`/collection/resource_id`)?


How to program for constraints/rules

First the background, during interviews in the past, many times I have been asked to design some or other variation of card game as programming puzzle, and I have tried to design it in OO way, but I have never been satisfied with my solutions. However it was not until recently that I realized that I had been approaching the problem from the wrong direction. Specifically I was trying to solve the problem by modeling individual card as an object. Problem with this is individual cards don't have any non-trivial intrinsic behavior and therefore are not suitable (or primary) candidate as objects. What is interesting and important about cards are rules and constraints, such as there could be only four suits, or only thirteen cards in each suit. Of course, then there are any number of rules for games. So my questions are   1. Are there any idioms/constructs/patterns to program for rules & constraints.    2. How many in 1 can be applied in conjunction with OO paradigm.


Rewriting code under BSD license

I am currently studding OpengGL with OpenGL Supebible 5th edition. I've found interested for me some C++ code that is distributed with the book (see also on google code). That code is under New BSD License. I am writing my software on C# with SharpGL wrapper and I'd like to know following things:   1. Can I rewrite that C++ to C#? **edid:** I'am interesting in using such things like GLBatch, GLShaderManager and some other thing from GLTools. Problem is that library is on C++, but I use C#.   2. How do I have to mark my source code if I put it somewhere like to my github account?    3. What disclaimer should be? Original disclaimer looks like:               /* GLShaderManager.h          Copyright (c) 2009, Richard S. Wright Jr.     All rights reserved.          Redistribution and use in source and binary forms, with or without modification,      are permitted provided that the following conditions are met:          Redistributions of source code must retain the above copyright notice, this list      of conditions and the following disclaimer.          Redistributions in binary form must reproduce the above copyright notice, this list      of conditions and the following disclaimer in the documentation and/or other      materials provided with the distribution.          Neither the name of Richard S. Wright Jr. nor the names of other contributors may be used      to endorse or promote products derived from this software without specific prior      written permission.          THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY      EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES      OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT      SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,      INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED      TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR      BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN      CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN      ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     */      **Edit:** Should my copyright looks like after rewriting something like that?               Copyright (c) 2014, My Name          Copyright (c) 2009, Richard S. Wright Jr.     All rights reserved.          Redistribution...................


Commercial use for embedded system

I am developing a embedded system (computer + os + programs) to sell it to a company. I am confused about the licensing and the softwares I wanted to use to develop the system.So I want to know if I can use these programs free of charge and without distributing the source code for commercial use.I wanted to use:   * A linux distro o custom linux build:I thought Arch Linux   * A Web Server + PHP + MySQL: I thought XAMMP,they says that is free of charge for commercial use but I don't know if the components are also.   * A QT backend and frontend,but I don't know if I can use the LGPL version for commercial use or I need to use the Commercial License.   * jQuery (I saw that if I maintain the notice,I can use it) Thanks for your response


Prevent 3D model from being copied

So I have been messing around with thingiview since I wanted to have a 3D viewer for the models on my site. It works great and everything except one problem. It's nothing wrong with thingiview, it is the fact that since the model is loaded into the browser, that means the model could also be copied. So my question is, is there a way to prevent a 3D model file that is loaded into thingiview, which uses three.js from being copied freely. The only idea I can come up with that is copy proof is to have snapshots generated and then the user could just view the snapshots, but that sucks compared to being able to actually view the file. So any ideas?


What discipline does Computer Science belong to?

Is Computer Science science, applied mathematics, engineering, art, philosophy? "Other"? To provide background, here is Steven Wartik's blog posting for Scientific American titled "I'm not a real scientist, and that's okay." The article covers some good topics for this question, but it leaves open more than it answers. **If you can think of the discipline, how would computer science fit into its definition?** Should the discipline for Computer Science be based on what _programmers_ do, or what _academics_ do? What kind of answers do you get from people who've seemed to think deeply about this? What reasons do they give?


Algorithm for percentage without knowing total number

Suppose there are `n` lines for a hotline. Whenever a customer calls the hotline, the call is forwarded to one of the `n` lines. And I want to assign percentage of calling to each of the n lines. Suppose there are two lines and one line is assigned 60% and other is 40%, the total number of calls is 10 so the first line would receive 6 calls and second will get 4 calls. I know the percentage of calling to each line in advance but the problem is that I don't know the number of calls that would be received in a day. **How can I distribute the number of calls without knowing the total calls?**


Developing a feature which sole purpose to be taken out?

What is the name of the pattern in which individual contributors (programmers/designers) developed an artifact for the sole purpose is to serve as a diversion so that **_management can remove that feature in the final product_**? This is a folklore I heard from an ex-colleague who used to work at a large game development company. At that company, it is well known that middle management is pressurized to "give inputs" and "make changes" to the product otherwise they risk being seen as not contributing to the project. This situation have delayed many projects because of these superfluous "management inputs". In one project at the above company, the artists and developers created a supernumerary animated character that appears in every cutscene and sticks out like a sore thumb. They designed it in such a way that it can be easily removed before the game is shipped (this was when games were still sold in physical media and not a downloadable product). Obviously the management then voted to remove the animation. On the positive side, _management didn't introduced any unnecessary changes that would have delayed the project_ because they have shown that they provided constructive inputs to the product. This **_process pattern_** has a name among game programmers that work in corporates, but I forgot what was the actual name. I believe it's duck- _something_. Anybody can help pointing out the name and perhaps some rather credible reference to how the pattern develops?.


Is there a known standard data structure which is a hash table that resolves collisions using a binary tree? If so what is the name of this data structure? I imagine such a structure would be useful as it should reduce the worst case search time down to O(log(n)) compared to O(n) in a hash table, and the best case would still be O(1).


Why do we need URIs for XML namespaces?

I am trying to figure out why we need URIs for XML namespaces and I cannot find a purpose for that. Can anyone brighten me a little showing their use on a concrete example? **EDIT:** Ok so for instance: I have this from w3schools               <root     xmlns:h="http://www.w3.org/TR/html4/"      xmlns:f="http://www.w3schools.com/furniture">           <h:table>        <h:tr>          <h:td>Apples</h:td>          <h:td>Bananas</h:td>        </h:tr>      </h:table>           <f:table>        <f:name>African Coffee Table</f:name>        <f:width>80</f:width>        <f:length>120</f:length>      </f:table>           </root>      So what should `http://www.w3schools.com/furniture` hold ?


UML class diagram - can aggregated object be part of two aggregated classes?

Some sources say that aggregation means that the class owns the object and shares reference. Lets assume an example where a company class holds a list of cars but departments of that company has list of cars used by them.               class Department     {        list<Car> listOfCars;     }          class Company     {        list<Car> listOfCars;        //initialization of the list     }      So in UML class diagram, I would do it like this. But I assume this is not allowed because it would imply that both company and department own the objects..               [COMPANY]<>------[CAR]     [DEPARTMENT]<>---|        //imagine this goes up to the car class


Is retaining intermediate objects as member fields a good idea in this case?

I'm currently writing a series of classes in java that are meant to translate a regular expression (written with the formal definition, not language- specific shortcuts) into a deterministic finite automaton. To make the DFA, it first converts the regex to postfix, then to a syntax tree, then to an NFA, then finally to the DFA, which is then minimized. Should I keep a reference to each intermediary object as a member of the object it was used to create? e.g. A reference to the syntax tree in the NFA, and a reference to the NFA in the DFA? They're not publicly accessible, so are they just unnecessarily bloating the classes and the program?


Quantifying the advantages of a modern version control system

I've worked as a team lead/developer in a large financial enterprise environment for the better part of three years. Our production release process is a nightmare because it revolves around Clearcase. We have a change management group who executes all releases and who will only allow code into production that was taken from it. One of the first things I did when joining was to set my team up with Git. Everyone agreed that Clearcase was awful and was impractical for handling day- to-day source control matters. So we set up a sort of "unofficial" repository on my local machine and I wrote a script to sync our git and Clearcase repos around release time. Word of this spread to other teams and several have adopted the same process. Using git in an "unofficial" manner for day-to-day activities and "officially" using Clearcase for releases. I've become sort of the go to guy for any issues with Git. So I have a meeting this week with the SVP in change of infrastructure who specifically wants me to explain to her the merits of Git. Word apparently got to her of my frequent rants on Clearcase. If she accepts my arguments, I will have a real shot at helping my employer rid themselves of this abomination. My experience with executives tells me they a) want extremely terse explanations for everything b) are only interested in facts that involve dollar figures To a developer I can explain the merits of Git over Clearcase (or ANY other version control system over Clearcase for that matter), but I'm drawing a blank on how to do this to a technical executive without a technical background (she has an MBA and did her undergrad in geography). I feel any argument I make to her is either going to sound like technical gibberish or that I'm evangelizing my personal preferences. What I'm trying to find are concrete facts demonstrating developers work more effectively with Git, or ANY modern source control system. I think that the fact the other teams have started using Git internally is a meaningful sign, but it's still not strong enough because it can still be dismissed as personal preference. What I really need is something powerful enough to break through the "This process has worked for 20 years, why should we change it?" argument.


Are there areas where TDD provides a high ROI and other areas where the ROI is so low that it is not worth following?

Test driven development. I get it, like it. But writing tests does require overhead. So should TDD be used universally throughout the code base, or are there areas where TDD provides a high ROI and other areas where the ROI is so low that it is not worth following.


Do you know any studies on relation of productivity of a programmer and the workstation used?

I was wondering if there are any studies (formal or not-so-formal) that show correlation between a developer productivity and the workstation used to develop software. It is often heard as argument that the high spec workstations increase the productivity (or the low spec machines impact productivity to the greater extent). To me it sound reasonable, however I'd like to verify the statement with some studies if such exists. Can you help me with that?


What process do typical (the majority) of high level language compilers use when changing a source-code's variable name to a machine code name?

Do long (very long) variable names slow down the compilation of source code? I'm aware that the length of variables has 0% impact on interpretation as the compiler changes them to machine code which is always the same length. But my question is, does the speed at which the compiler vary depending on the length of variables? For example, if I have a variable name which is a million characters long, surely the compiler would struggle as for it to recognise the variable **is** a variable, it would need to read the entire thing first which would surely take longer depending on its size? To clarify, what process do typical (the majority) of high level language compilers use when changing a source-code's variable name to a machine code name? Do they find the start of the variable working from the left and then find the end working from the right, do they read through the entire variable name (one character at a time) until the end is found or do they not even look at the variable name at all and just know that the code requires a variable of type int (for example) and assign it a machine-level name instantly and then completely ignore any user-defined variable names? Note that I am a complete novice (still a student) so excuse my ignorance if I get my terms mixed up.


How to motivate team for knowledge sharing sessions

I work in a team with wide range of expertise and experience. I have been trying to introduce weekly knowledge sharing sessions. Sessions of 30-60 min length where everybody gets a chance to present something and talk about it. This will contribute in improving presentational and language skills. However, the team is not motivated towards this, either the attendance is too low or none. How to get a team work towards such an idea?


Sequence diagram should consist of View objects, DB objects, etc.?

I read many articles, and saw a lot of images and I can't answer the question whether objects of View classes or DB classes should be contained on the sequence diagram or it should be more generalized?


Should I create inner class here or leave as is?

Folks, I have two separate classes. One of them makes http requests/receives response to/from a server and the second one converts received JSON objects into my models (separate classes). I'm thinking it would be an idea to include this class for data converting as an inner class of my first class. Wouldn't my first class be extra big because of it and I need to leave everything as is or this is a good common practice to behave like that?


Where are the next-next-generation editors?

I was reading an old Coding Horror article about indentation, when I read this: > Or, maybe you're using a next-next-generation editor that treats code as > "data" and the layout (including whitespace) as a "view", making all these > concerns largely irrelevant. Exactly what next-next-generation editors was Jeff Atwood referring to?


How do you ascertain the quality of a potential employer's code before you take a position?

In my experience before you start working for a company you have no opportunity to look at the code-base (I've asked and for reasons of confidentiality everyone has always said no, I think that is fair), so during the interview process what do you think are the most important questions to ask to find out what kind of state the code is in (after all, if it's a dog, then you are going to be on of the poor unfortunates who has to walk it every day)? **UPDATE:** A check-list: Ask;   * What _they_ think of the codebase. And when you do, pay close attention to facial expressions and the time it takes for them to respond. [Anon]   * What is the company's CMM level [DPD] (and if you hear Level 5 run the other way [Doug T])   * What lifecycle they use [DPD] (And if you do hear "Agile", that's when you start asking some penetrating questions to try to figure out if by "Agile" they mean "Agile or "cowboy coding" [Carson63000])   * What tools they use to asses code quality? [DPD]   * What tools they use for development? [DPD] (Look for refactoring tools and continuous build servers)   * What source code (version control) system they use, and a good follow up is to ask why they use it. [Zachary K].   * What are their testing procedures like? [Karl Bielefeldt] (Look especially for teams that use mocking frameworks and place an emphasis on thorough automated unit testing through established frameworks like NUnit / JUnit; don't be put off by teams that don't use test driven development TDD, but be wary if they don't consider testing to be integral to and the cornerstone of solid software development. Look for teams with dedicated testers.)   * What kinds of assignments are given to new developers? To experienced developers? [Karl Bielefeldt]   * How many people work on a project? [Karl Bielefeldt]   * Is refactoring allowed? Encouraged? [Karl Bielefeldt]   * What quality-related process or architecture changes are under consideration or have been made recently? [Karl Bielefeldt]   * How much autonomy do individuals have over their modules? [Karl Bielefeldt]   * Will you be developing newer projects (greenfield development) or legacy projects (brownfield development)? (Greenfield development is generally more fun and has less problems as you aren't cleaning up with someone else's mistakes).   * Is the employee turnover rate is high in the organization or the team? (This often indicates lower quality of code) [M.Sameer]   * Some programming problems of your own; but avoid seeming like a jerk. [Sparky]   * How do the developers collaborate and how is knowledge shared amongst the team? (This should match your personality; I would say a mixture of solo and pair work is probably best, with the ratio matching your social needs)   * How close their database is to 3rd Normal Form (3NF), and if it deviates where and why? (If they say "3NF???", leave. If not, and there might be good reasons for it not, then find out what they are). **NOTE:** I've accepted Anon's answer because after about a week the community thinks that it is the best one - I think this suggests that it is just something that you somehow need to develop a sixth-sense for. But, I think everyone has had something valuable to say.


How does freelance job operate?

I want to find a freelance job, but I've never done any freelance work before. I want to know what the process involves. Can you please answer the following questions?   1. If the programmer finds a suitable freelance job, how can they apply, and how will the future employer evaluate the programmer's abilities?   2. How does the programmer deliver their work?   3. How does the programmer receive money? What if the employer and the employee are in different countries? How do they pay?   4. Do you really read the agreement when signing an account on a freelance website?   5. Any pitfalls? Under what circumstances will the employer not pay after the work is done?


Multi MVC processing vs Single MVC process

I've worked fairly extensively with the MVC framework cakephp, however I'm finding that I would rather have my pages driven by the multiple MVC than by just one MVC. My reason is primarily to maintain an a more DRY principle. In CakePHP MVC: you call a URL which calls a single MVC, which then calls the layout. What I want is: you call a URL, it processes a layout, which then calls multiple MVC's per component/block of html on the page. When you compare JavaScript components, AJAX, and server side HTML rendering, it seems the most consistent method for building pages is through blocks of components or HTML views. That way, the view block could be situated either on the server or the client. This is technically my ONLY disagreement with the MVC model. Outside of this, IMHO MVC rocks! My question is: What other RAD frameworks follow the same principles as MVC but are driven rather by the View side of MVC? I've looked at Django and Ruby on Rails, yet they seems to be more Controller driven. Lift/Scala appears to be somewhat of a good fit, but i'm interested to see what others exist.


Education vs. Experience

I'm going through a rough time. I'm a CS student at UIUC, which I hear is one of the top schools for CS. I love computers and programming. I've been pretty much doing it my whole life. I'm a freshmen now (junior in actuality, but I was premed before I switched to CS-long story). I'm finding the cirriculum pretty hard and challenging, but of course this way you learn so much. Due to the challenging nature of this program, especially at this school, I dont always get the top scores, while others seem to have no problem. I get discouraged quickly, and say to myself something like "whatever, I know even if I dont finish this program, I will find a way to make it on my own". Of course, I only say this to make myself feel better about my situation. But I really want to graduate from here and get this degree, but I find myself losing more and more motivation by the day. For those of you that graduated with a CS degree, any tips on how to get through this? Also, what are the benefits of a CS degree? I heard that I wont even use half the stuff I learn here. Why cant I just learn programming on my own by reading books. Most companies love experience. What does it come down to at the end? Of course I would love having this degree, but getting through it is gonna be a challenge.


We're Subversion Geeks and we want to know the benefits of Mercurial

Having read I'm a Subversion geek, why should I consider or not consider Mercurial or Git or any other DVCS. I have a related follow up question. I read that question and read the recommended links and videos and I see the benefits but I don't see the overall mindshift people are talking about. Our team is of 8-10 developers that work on one large code base consisting of 60 projects. We use Subversion and have a main trunk. When a developer starts a new Fogbugz case they create a svn branch, do the work on the branch and when they're done they merge back to the trunk. Occasionally they may stay on the branch for an extended time and merge the trunk to the branch to pick up the changes. When I watched Linus talk about people creating a branch and never doing it again, that's not us at all. We create probably 50-100 branches a week without issue. The biggest challenge is the merging but we've gotten pretty good at that as well. I tend to merge by fogbugz case & checkin rather than the entire root of the branch. We never work remotely and we never make branches off of branches. If you're the only one working in that section of the code base then the merge to the trunk goes smoothly. If someone else had modified the same section of code then the merge can get messy and you might need to do some surgery. Conflicts are conflicts, I don't see how any system could get it right most of the time unless if was smart enough to understand the code. After creating a branch the following checkout of 60k+ files takes some time but that would be an issue with any source control system we'd use. Is there some benefit of any DVCS that we're not seeing that would be of great help to us?


Questions to ask to ensure someone understands programming? (and iOS)

So, I've been tutoring my friend for 2 years. Most people learn programming on their own in 3-6 months, (sans algorithms). It's confusing 'cause he'll run anywhere I tell him to, understands how to read C and C++ honestly better than the average college student, and he'll modify and repeat anything I do... but for the love of god he doesn't move on to new things and he still has test anxiety. I've recently realized he's copied and toyed with existing, but not once gained an understanding of why. I was under the impression he was learning fast because he could write it, but when you say "Make a function that takes an NSString" and he says "How?" and I say "The same way you make ANY function that takes any parameter, NSString is just a type like int" and all I hear is "No, it's an NSString, it's a special thing." and we get into an arguing match 'cause I'm like "It's just a class like any other class, you've used them for months now" and blah... I've subconsciously avoided comprehension questions because of this. Anyway, if you have him copy a program and say "Just initialize it" "Where?" "I don't care, didLoad or initWithCoder or Awake from nib, anywhere it gets initialized" and "No, it has to be exactly where you had it!" "No it doesn't!" I'm sick of this, but he won't give up. So I'm done avoiding these yelling matches and becoming a sadist from now on. I would like some help in finding questions to ask him that force him to understand what he's doing. I'd like some help and any resources I can find. CQuestions looked like a good site, but now I need some iPhone stuff. For example: *What do properties do? How are they changed? How do you change the name of the getter? *Why are Booleans inefficent? What advantage does int have over a boolean and how does the bit-shift operator help? *What does Copy do to a string? *What's the difference between a view controller and a uiview? *Write a program from memory that displays blah on screen, and flashes each view one by one. From beginner up to intermediate, hobbyist with some algebra at most. I'm just looking for resources to work with. I left in backstory so you know to "twist" the questions so he doesn't know he's supposed to init a variable here or there, but has to figure it out, and learn why it goes "here" or that "anywhere is fine as long as it's". Sample programs, anything. I'm relatively open about this because, being a programmer, I seriously doubt he's the only one who has this issue. I'd like to know how others have overcome similar. What made things "click"? for you? Did you have a hard time finding answers on Google, and how did you learn a better way to find what you were looking for? (He's so exact, he'll search for how to write a checkers program with color X and Y inside a uiview, as his search string, instead of breaking it up into components, I need help with that too, and believe it is related). This type of problem has to remind one of us of someone they know. So, Exercises to force them to think? Ways we overcame this thing in the past? I greatly appreciate any help.