Why Java as a First Language?

Why is Java so popular as a first language to teach beginners? To me it seems like a terrible choice:   1. It's statically typed. Static typing isn't useful unless you care a lot about either performance or scaling to large projects.   2. It requires tons of boilerplate to get the simplest code up and running. Try explaining "Hello, world" to someone who's never programmed before.   3. It only handles the middle levels of abstraction well and is single-paradigm, thus leaving out a lot of important concepts. You can't program at a very low level (pointers, manual memory management) or a very high level, (metaprogramming, macros) in it.   4. In general, Java's biggest strength (i.e. the reason people use it despite the shortcomings of the language per se) is its libraries and tool support, which is probably the least important attribute for a beginner language. In fact, while useful in the real world these may negatives from a pedagogical perspective as they can discourage learning to write code from scratch.


Do you think is good to start developing Android Applications even though I'm a beginner? So should I just concentrate on learning java, c++, html, css, javascript, php, msql, c#, c, objective-c, etc?


Best development architecture for a small team of programmers ( WAMP Stack )

I'm in the first month of work in a new company.. and after I met the two programmer's and asked how things are organized in terms of projects inside the company, they simply shrug their shoulders, and said that nothing is organized.. I think my jaw hit the ground that same time.. ( I know some, of you think I should quit, but I'm on a privileged position, I'm the most experienced there, so there's room for me to grow inside the company, and I'm taking the high road ).. So I talked to the IT guy, and one of the programmers, and maybe this week I'm going to get a server all to myself to start organizing things. I've used various architectures in my previous work experiences, on one I was developing in a server on the network ( no source control of course ).. another experience I had was developing in my local computer, with no server on the network, just source control. And at home, I have a mix of the two, everything I code is on a server on the network, and I have those folders under source control, and I also have a no- ip account configured on that server so I can access it everywhere and I can show the clients anything. For me I think this last solution ( the one I have at home ) is the best:   * Network server with WAMP stack.   * The server as a public IP so we can access it by domain name. And use subdomains for each project.   * Everybody works directly on the network server. I think the problem arises, when two or more people want to work on the same project, in this case the only way to do this is by using source control and local repositories, this is great, but I think this turns development a lot more complicated. In the example I gave, to make a change to the code, I would simply need to open the file in my favorite editor, make the change, alter the database, check in the changes into source control and presto all done. Using local repositories, I would have to get the latest version, run the scripts on the local database to update it, alter the file, alter the database, check in the changes to the network server, update the database on the network server, see if everything is running well on the network server, and presto all done, to me this seems overcomplicated for a change on a simple php page. I could share the database for the local development and for the network server, that sure would help. Maybe the best way to do this is just simply:   * Network server with WAMP stack ( test server so to speak ), public server accessible trough the web.   * WAMP stack on every developer computer ( minus the database )   * We develop locally, test, then check in the changes into the server test and presto. What do you think? Maybe I should start doing this at home.. Thanks and best regards... Edit: I'm sorry I made a mistake and switched WAMP with LAMP, sorry about that..


Where do I go to hire a freelance programmer?

I want to hire a programmer freelance to develop a small InDesign plugin, but I have no idea how to go about finding one. Most of the freelance bidding sites are garbage, but aside from finding a few companies from a google search I'm not sure where else to go. Are there any good sites for posting jobs or other good ways of finding a programmer to hire?


Using NetBeans and Eclipse together

I'm working on a collaborative group project at university which involves writing a Swing application, an Android application and some Java data models and a JDBC connection. We've been taught to use NetBeans but will need to use Eclipse to write the Android application. I find NetBeans to have nicer GUI builders than Eclipse's Visual Editor plugin and the other group members want to use NetBeans as they are familiar with it. I can already foresee clashes as JFrame forms created in Eclipse won't open the interface builder in NetBeans. Does anyone have advice on using both of these programs together on a group project? At the moment the issues I'm seeing are:   * Lots of meta-files from each IDE (which I'm currently ignoring via .gitignore, is this a good idea?) cluttering the repository and potentially being out of sync with each other.   * The mentioned GUI problem, what does NetBeans look for when looking to show the Design view?   * Different templates being shown. I'm probably just going to stick with NetBeans until we get to the Android part but if there are ways to make them play friendly I'd love to hear them.


Workflow for a plugin assignment

I'm starting a new project in PHP, a plugin for a website that grabs additional data from it through cURL, getContents etc and re-tabulates it in excel. It's a local project, basic script like with a very limited UI. Iv'e been using Codeigniter and it's a great framework for websites, and even the Twitter application I'm using it for but I don't think I need MVC (necessarily) for this small project but I also don't want to go bare. What would your typical workflow be for this kind of weekend assignment where your creating a local do-something script or like in my case adding functionality to a website? Is there something in between a light weight MVC framework and a blank page?


Which .NET REST approach/technology/tool should I use?

I am implementing a RESTful web service and several client applications that are mostly in Silverlight. I am finding a litany of options for developing both the server-side and client-side of the API but am not sure which is the best approach. I'm concerned about stability as well as a platform that will continue to exist a few months from now. We started using the REST Starter Kit with .NET 3.5 but moved to the new WCF Web API when updating to .NET 4.0. All of their documentation indicates that WCF Web API is the replacement for the RSK. However, Web API is only in Preview 4 and does not include support for Silverlight or Windows Phone 7 clients (yet). WCF Web API looks like a wrapper on top of the WCF WebHttp Services stuff provided in the `System.ServiceModel.Web` library which makes me think that maybe it would be simpler to just go with the built-in stuff but Web API does offer some nice features. I am specifically tied-up trying to determine the best course for the client- side. My main requirement is that I need to support deserializing into my client-side objects quickly and easily. The Web API offers a nice client library but doesn't have a Silverlight version. I'd like to use the latest approach and the toolset that is being actively developed and supported.   1. Is the REST Starter Kit really obsolete?   2. Has anyone had any success implementing the WCF Web API toolkit?   3. Is there merit to using either of these over the built-in WCF WebHttp Services features found in `System.ServiceModel.Web`?   4. Is there a single solution that works for any client (web, Silverlight, etc.)? What suggestions do you have?


What does your Lisp workflow look like?

I'm learning Lisp at the moment, coming from a language progression that is Locomotive BASIC -> Z80 Assembler -> Pascal -> C -> Perl -> C# -> Ruby. My approach is to simultaneously:   * write a simple web-scraper using SBCL, QuickLisp, closure-html, and drakma    * watch the SICP lectures I think this is working well; I'm developing good 'Lisp goggles', in that I can now read Lisp reasonably easily. I'm also getting a feel for how the Lisp ecosystem works, e.g. Quicklisp for dependencies. What I'm really missing, though, is a sense of how a seasoned Lisper actually _works_. When I'm coding for .NET, I have Visual Studio set up with ReSharper and VisualSVN. I write tests, I implement, I refactor, I commit. Then when I'm done enough of that to complete a story, I write some AUATs. Then I kick off a Release build on TeamCity to push the new functionality out to the customer for testing & hopefully approval. If it's an app that needs an installer, I use either WiX or InnoSetup, obviously building the installer through the CI system. So, my question is: as an experienced Lisper, what does _your_ workflow look like? Do you work mostly in the REPL, or in the editor? How do you do unit tests? Continuous integration? Packaging & deployment? When you sit down at your desk, steaming mug of coffee to one side and a framed photo of John McCarthy to the other, what is it that you _do_? Currently, I feel like I am getting to grips with Lisp coding, but not Lisp development ...


How deeply programmer should know about internals of database engine?

I am learning SQL Server 2012 along with C#. In the past, I took database class in college, and have good grasp on SQL language and can write queries. However, looking at SQL Server documentation (or Oracle), it appears that DB engine (along with all the technologies that comes with it) are highly complex and are requiring significant time and effort to learn. Besides writing SQL queries, how deeply should programmer know about internals of database engine ?


What is "train" based development?

I ran across yet another new term in development methodology, and I haven't been able to find a definition for it. Specifically, it's called "train based development." Here are some examples of where I have seen this term. > Earlier this week, I asked our engineering leads and release managers to > take the Windows Metro version of Firefox off the trains. (Johnathan > Nightingale) https://blog.mozilla.org/futurereleases/2014/03/14/metro/ From the Mozilla careers web-site: > Experience working with both agile development methodology, and train-based > development/QA teams. I have heard of "train" before and not just in the context of Mozilla. But I haven't managed to find any good information about it on the net. When I googled "train based software development", I found very little information in the search results. The closest that I could dig out that separates the train from the wagons is that "train" is about making releases at regular intervals according to a schedule. But it also seems that "train" is a sort of concrete QA setup. **So, what is "train based development"?**


How to teach a script to detect sarcasm?

I'm currently building a fun script, that basically matches given phrases and gives a predefined response based on the match-points. You can ask it to retrieve some information based on live feeds, run tasks, tell anecdotes or just chat with her. I already have built-in detection for badwords, caps lock or both. The program has a girl name and I tried to make as close to being a girly-girl as possible, on the logic terms (for example: everybody knows that most girly- girls take 700ms to respond to a question, joking of course). So here is a little example: > Client: WHAT IS YOUR PROBLEM?   >  Kiku: DONT USE THAT TONE WITH ME!   >  Client: #### you   >  Kiku: why are you being so mean to me :/ However, I really would like to add sarcasm-feature to it. So if you write something in sarcasm, then she will detect it and respond accordingly. Now this is a tricky part, **How do you teach a script, what sarcasm is?** To me more specific. What are the most common sarcastic words used today? Or how to get that statistic? How can I make the script understand the context of the given phrase? **UPDATE** As this question is getting alot of hype, I think things should be cleared out a bit more. It is very clear, that making a script fully detect sarcasm is basically impossible. At least in reasonable matter. However, I do believe that some amount of **possible** sarcasm could be detected. I currently have made it so far, that my script can detect a very limited sarcasm. I predefined some common sarcastic-words (however, alone they are useless.) For example: **like, whatever, yeah, right and great.** And then it first matches, the simple things, like uppercase and quoted: `THANKS you are so smart` or `oh you are so "SMART"`. Since the scripts main function is to do tasks or retrieve information, and afterwords it will ask if that was what you meant. Then I thought, adding "thanks" as a special variable. So `yeah thanks` or `whatever thanks` will trigger the possible sarcasm, and the script will ask you: "Do I detect sarcasm?" Your best bet would be to say "sorry" then, otherwise it will add a warning-point and if the limit is reached -- it will start ignoring you. As these very very simple algorithms seem to actually work, then this idea has a future, of course after alot of tuning and tweaking. However, is somebody alot smarter would make a open-source software with the same idea in mind. Then this feature could be hooked to alot of functions on the web. Customer care would probably benefit the most, however, this kind of software could also be used detecting "flaggable"-content.


Editing Copyright line in Apache2 license.txt

I wish to publish my program under Apache2 license. I have added the "APPENDIX" part of the license text to the top portion of my source.txt file and edited the copyright year and name. But when I add the license.txt file in the same archive with sourcecode, should I edit the copyright line wih my name and year? Or should I let the copy of license.txt intact as downloaded from apache site?


Best Practice For Usage of Shall and Must While Writing Requirements

I sent out an email earlier reminding our developers that, _the use of the word, 'Shall', in your derived requirements should not follow over to your functional requirements. When writing functional requirements the word, 'Must', is used to describe the function a derived requirement must do.   Derived = System Shall be requirement   Functional = System must do requirment_ It was sent back by one of our Seniors that, that was wrong and that shall should be used in every requirement. Am I wrong here and Shall should be used in every requirement. I haven't been able to find anything to back that up.


Is path coverage stronger than condition coverage?

I have encountered (even in literature) two contradicting opinions related to path vs condition coverage (not branch or edge!). Some say Path coverage is stronger than the condition coverage, some say the opposite. Having code like this:               If(X<0 OR X>100)        DoStuff();      _Path coverage_ \- 1 test case is needed to cover the path. With X=-1, the second expression will not be tested and possible bug will be missed.   _Condition coverage_ \- test cases X=-1 and X=100 are needed to test both conditions. Am I missing something or condition coverage is really stronger than path coverage? **Condition coverage (ISTQB):** > **Our next level of coverage is called condition coverage. The basic concept > is that, when a decision is made by a complex expression that eventually > evaluates to TRUE or FALSE, we want to make sure that each atomic condition > is tested both ways.** _Practical Insight Into CMMI_ > Condition coverage measures the true and false outcome of each Boolean > subexpression. **References:** _Software Testing: Principles and Practices from Srinivasan Desikan,Gopalaswamy Ramesh:_ page 61 > Condition coverage is a much stronger criteria than path coverage, which in > turns is a much stronger criteria than statement coverage.


How to allow multiple plugins to provide data for multiple aggregation processes?

I'm working on a Java project in which we want to have data collection plugins that collect data to be processed by one or more data aggregation modules. The plugins will all written in-house. Say for example we have data collection plugins A, B and C and data aggegration module X. The modules A, B & C input data into tables that are different but have a few certain fields in common that X cares about. Sometimes the names of the fields are different, but as far as the algorithm is concerned they are "the same". What's the best way to get X to operate on these different data sources while still allowing for a new data collection plugin D to be integrated, as well as the possibility of a new aggregation module Y that operates on some or all of the data sources? My main concerns are about dependencies - for example, should the data collection plugins know about the aggregation modules, or the other way round? Or neither? Should the collection plugins implement interfaces that the aggregators can then make use of, and if so then where should be interfaces be defined?


What is the regarded current best practises regarding the "this" keyword in front of field and methods in c#?

Unless it is needed to differentiate between a variable and field with the same name, I never put `this.` in front of a field or any member access in C#. I see this as no different to `m_` prefix that used to be common in C++, and think if you really need to specify that it's a member, your class is too big. However, there are a number of people in my office that strongly disagree. What is considered current best practises regarding `this.`? EDIT: To clarify, I never use `m_` and only use `this.` when absolutely necessary.


IS C++ a cross-platform language?

If I create a game in C++ on a mac using a library which is the same for both windows and osx, will the game be playable on both windows and os x or it will only work in os x because I done it in Xcode? Is SDL a great library to do your first game after learning the basics and syntax of C++ (I found syntax to be close to Java)?


Handling and organizing data from save file?

I'm working on a webapp (python/javascript) to modify a game's save file. The file has certain bytes representing player information, such as the gun, the equipment, etc. The idea is to show an interface representing the information in the file, allow the user to make changes, send the data back to the server, which modifies the file, and allows the user to download it. My problem is that I don't know which functions should be handled in javascript, and which in Python. I need python for reading the file, but does that mean I should use it to handle the data? If I read the information into relevant variables to send back with JSON, is it redundant because I'm not doing anything with the information in Python other than sending it back? I've currently been indecisive about two possible ways to go about it. One, and this is the way I currently have it set up, is to handle the file with Python; figure where certain things are, read them into dictionaries, turn it into json, send that to javascript, and then parse the json and update the gui. As I said before, this feels like the wrong way to do it. The other thing I was considering was to just read the entire file and send that back to javascript to work with. This also seems really incorrect. Javascript (at least as it's implemented in browsers) isn't meant to handle files, and packing/unpacking functions would have to be custom - one of the things I'm seeing as a red flag about this method. The files are only about 1-2kb, so that wouldn't be a reason not to send it back to the page. In fact, the json I'm sending back is larger than just the contents of the file would be. Still though, I don't much like the idea. So what do I do? I'm also having trouble organizing the actual code. I know it's bad practice to stick a lot of code into a single function, but dividing into many other functions has made it hard to keep track of things. Is there a good language-agnostic book that will help me with this?


Need a file location in Business logic layer from UI layer

Here's what I'm doing: I am reading a file in BLL, which is sitting in the UI layer. Currently the application is using `HttpContext.Current.Request.PhysicalApplicationPath` to find the absolute path written in BLL. I feel this is not a good design and I am thinking that I should pass this information in some kind of structure to BLL or I could use a helper method to get that. Please let me know which one is better and if there are any better solutions / suggestions. Please ask if you need more details.


Should I use chained functions in Java?

From time to time, I'll have a class in Java that takes a multitude of parameters, however, sometimes when I am creating an object of this class, I don't need to use all the parameters. As of now, I usually set the parameters to null or 0 depending on the type. However, would it be easier if I just created chained methods to set certain fields in the class? So, instead of: `MyClass someInstance = new MyClass(param0, null, null, 0, null, param5);` Have something like this: `MyClass someInstance = (new MyClass()).setParam0(param0).setParam5(param5);` Does this go against OOP or Java's usual paradigm?


Is @staticmethod proliferation a code smell?

Consider a Python class with a number of `@staticmethod` methods and few instance methods. The static methods don't accept an instance of the defining class as parameters.   * Do you think that all these static methods don't belong to the class and should be factored out?   * If yes, which approach would you take to clean up such code?


If you were to build an app like Craigslist, would use an off-the-shelf framework or write your own?

Title is the question. And why I am asking is because from what I read about most PHP frameworks (e.g. Code Igniter, Kohana, Cake, Zend) is that they're ether too complex, or are designed mostly for small applications (like blogs).


How should an embedded OS be combined with user code?

As a side-effect of an embedded project I've been working on, I've developed a small operating system for an ARM processor. While the OS and my user code are in separate directories and have clean boundaries between them, they're built into a single image using a single Makefile. I'd like to release the OS as open source. It consists of an exokernel and userland driver libraries. What I'm trying to decide is how a user of this OS should combine it with their own code at build time so they have a single image to flash. I can think of three possibilities: 1) Have the user include the OS source files as part of their project. They'd be recreating the setup I currently have, and it's how FreeRTOS, for example, appears to do it (although it only has three files). 2) Have the OS build itself into a .a file that the user code can link with. That would allow the user full control over memory placement using their own linker script (and allow the linker to tell them when a combined text, BSS or data section exceeds its space). 3) Have the OS build itself into a raw binary that expects to have the user code concatenated onto the end of it. The user code would begin with a small header (placed by the linker script) that had the address of the main function. The user code would also link with a .a file of just the userland drivers, not the kernel. (1) would make it easiest for me to develop the OS and my user code in parallel with git subtree. (2) seems to have the most useful link process. (3) gives the biggest separation. If you were using it, which would you prefer and why?


Applications of heapsort

Heapsort is a sorting algorithm that has a time complexity of O(nlogn), and performs sorting using O(1) space complexity. However, I know that because it's unstable, it doesn't find many applications (f.e. compared to other sorting algorithms). I know it's used for interval scheduling. **What are some practical applications of heapsort?** **EDIT:** As @AProgrammer pointed out, quick sort isn't stable either.


What is the difference between a non-functional requirement and a quality attribute?

I'm trying to understand the difference between non-functional requirements and quality attributes. Are they the same thing? You can find a set of quality attributes in the ISO9126 standard. I know that each system is defined by a set of functional requirements and every of this requirements has associated one or more quality attributes. For example, suppose that you have the requirement that describes the login functionality of a system. You can associate to that requirement the attributes of security and performance. If i say that the system can not take more than 1 second to respond, I'm talking about a constraint. So, where the concept of non-functional requirements kicks in? Are they defined by the users? How can I identify them?


Are you obliged to provide old employers with access to protected resources?

Firstly, a disclaimer. This question is not because I'm a disgruntled employee planning to hide some malicious code which I can later blackmail my employer with. I actually quite like the people I work with - just simply curious. So if an old employer needed a password for some resource that only I had. Would I be obliged to give it to them or could I (probably unwisely) stick it to them and either refuse or charge an outrageous "consulting" fee for providing that password? Or what if I designed some component for them like some sort of underlying encrypted security layer that required some a hash key that only I had, would I be obliged to give it to them? These two scenarios are generally the fault of the employer, but what if in the third scenario, I built this component in stealth, without them actually knowing? I don't necessarily mean the component was built with the sole intention of locking the employer out in the future, it may have actually served a good purpose - it just never got documented how it functioned because company had poor documentation processes or developers were too busy etc. In that scenario, when they finally need this hash key, would I be obliged to provide it?


terminologies and design/process clarification

I work at a BPO, actually a call center. My bosses saw the html tool I made to help me document customer concerns and steps I made to help them faster and more easy. With that, they made me the reporting guy. Then they asked me to create a executable file (.exe) which generates the stats or metrics of agents. I used c#, and ms access for the database for it. It took me 6 months to finish it, on my own. But I feel that's kind of a long period for a project like that. And when I look at my codes, I'm not satisfied myself. I really want to pursue programming/software development. Its just that I don't have proper training or education for it. I took computer engineering in college but my school isn't that good (I want to share the reason why but it'll just make this post longer). I've been doing research, reading ebooks about programming but I still can't grasp the essence of it. It's like, I can easily learn a language, IDE, technology etc., but I can't put them together. Can you, experts, tell me how I could see the bigger picture? Can you help me understand the following:   1. How are companies that makes/provides software solutions/programs start a project? Or how do they make them, in terms of process?   2. I've been seeing terms like software tester, unit testing, automation test etc. What are those and why are they being used or incorporated in the process? I have so much questions to ask, but when I try to post them, I tend to forget them, like at the tip of tounge. I hope you experts, can shed some light on those questions. I'm not trying to solicit points, but I really want to use the chat feature here so that when I have a quick question and learn more about programming/software development, I could easily chat with experts.


A testing environment for JavaScript other than browser?

When I want to test something in JavaScript, I open up a new browser window (mostly Firefox) and start writing code in the provided console (mostly Firebug). However, this tends to be really tedious and slow. Is there an environment, like an IDE with self-execution capability for example, in which we can test JavaScript? Guide: I'm looking for something like jsfiddle, but not in the browser, and not online. I'd like to have an execution environment which is both off-line, and is not a browser. All I'm asking is to have something like the Firebug Console as a separate applications (preferably Windows application) which can be opened by double- clicking, and in which, you can write JavaScript code and hit execute. That's all. In simpler terms, all I want is Firebug's console, without Firefox. Do we have such a thing on the market?


How do you call a "Proxy" that delegates to *several* implementations?

In a traditional GoF Proxy, you have an Interface, an Implementation, that implements the Interface, and a Proxy that also implements the Interface, references an instance of Implementation, and delegates the calls on the Interface methods to the same methods in the Implementation instance. Say you would call the Interface/Implementation pair a "Fragment", and you would have several different such pairs. Now imagine you create a Whole Interface that implemented all those Fragment interfaces, and a single Whole Proxy that implemented the Whole Interface, and delegated to the appropriate Fragment Implementation instance. A code (Java) example:               // Fragment A:     interface FragmentA { ... }     class FragmentAImpl implements FragmentA { ... }     // Whole A. That is the interface that "clients use"     interfaces WholeA extends FragmentA { // EMPTY! }     // *automatically generated* Proxy:     class ProxyA implements WholeA {         private FragmentA implA;         // Implements FragmentA through delegation to implA     }          // Fragment B:     interface FragmentB { ... }     class FragmentBImpl implements FragmentB { ... }     // Whole B. That is the interface that "clients use"     interfaces WholeB extends WholeA, FragmentB { // EMPTY! }     // *automatically generated* Proxy:     class ProxyB extends ProxyA implements WholeB {         private FragmentB implB;         // Implements FragmentB through delegation to implB     }          // Fragment C: similar to Fragment B, but with different *added behavior*.      Is this pattern at all (since Patterns must be common solution to common problems)? And if so, as it got a name? Or could it be cleanly defined as a combination of patterns? Being able to clearly describe how this code works in terms of patterns would make it much easier to explain to others how create compatible code, and help to find a framework that already implements this pattern. A _Proxy_ normally delegates to _a single instance_. A _Facade_ normally offers _a different interface_ to that _multiple objects_ it hides. A _Bridge_ also offers _a different interface_ to that the _single instance_ it hides. A _Composite_ expects all components to _share the same base interface_. A _Decorator_ extends the interface of the wrapped object, like here, but normally _implements the additional functionality itself_ , instead of delegating to another objects. A Whole that implements a single Fragment is just a Proxy pattern, but a Whole that extends another Whole is closest to a Decorator pattern. There are several reasons to do it this way. Firstly, client code should see WholeB as extending WholeA, although the implementer of FragmentB cannot extend FragmentA (which was implemented by someone else). Secondly, references to WholeX (ProxyX) stay valid, even if implementation of FragmentX is replaced a runtime. Thirdly, both ProxyB and ProxyC can share _the same instance_ of FragmentAImpl.


Class Design for special business rules

I'm developing an application that allows people to place custom manufacturing orders. However, while most require similar paperwork, some of them have custom paperwork that only they require. My current class design has a Manufacturer class, of which of one of the member variables is an array of RequiredSubmission objects. However, there are two issues that I am somewhat concerned about. First, some manufacturers are willing to accept either a standard form or their own custom form. I'm thinking of storing this in the RequiredSubmission object, with an array of alternate forms that are a valid substitute. I'm not sure that this is ideal, however. The major issue, however, is that some manufacturers have deadline cycles. For example, forms A, B and C have to be delivered by January 1, while payment must be rendered by January 10. If you miss those, you'll have to wait until the next cycle. I'm not exactly sure how I can get this to work with my existing classes—how can I say "this set of dates all belong to the same cycle, with date A for form A, date B for form B, etc." I would greatly appreciate any insights on how to best design these classes.


How to convince my teammates that spawning numerous threads is a bad design?

I've stumbled upon this problem when tried to run our application in bad network conditions; it spawns hundreds of threads (which exist long time before termination), and with time the application crashes. However, other developers answered this is "not a bug" and "as designed".   I have a strong gut feeling that spawning so much threads instead of using async calls is defective design, in the first place. However, my teammates disagree.   Any ideas how I can convince them? UPD can I say that spawning threads for short running tasks is a bad design? What arguments I can use to support this statement?


Re-architecting a classic inheritance design

I have the opportunity to rewrite a core piece of a project (C#) that is inheritance-heavy and feels increasingly restrictive in how it is designed. The scenario is pretty simple, imagine an application that is built to handle various small tasks. Every task is unique in it's functionality so it implements an ITask interface with a few simple methods that get implemented by each task class (e.g. Init(), Start(), Stop(), etc). In addition to the ITask interface there is also an abstract BaseTask class that all tasks inherit from. This BaseTask class is sort of an 'everything but the kitchen sink' approach that contains useful pieces of functionality that the tasks often require. For example, all tasks record their status and progress the exact same way so this logic is defined in the BaseTask and available to all children through a protected method. Or to give another example, some tasks have to send email notifications out when certain conditions are met, so again, the BaseTask provides access to the core smtp functionality of the app for this purpose. There are many examples of these kind of 'helper' methods/properties The problem of course is that this base class has already grown unwieldy and cluttered with properties and methods that are not universal to all tasks and it's starting to introduce more problems than it is solving. For example, anytime a change is required to the base class you find yourself in a position where you might wind up breaking some (or all) of the tasks. It also just seems like its breaking encapsulation and the single responsibility principal. It's also quite clear how this happened in the first place (and a common occurrence too). Initially this was a very small, specialized application but it blew up in terms of scope and size very quickly and what was initially probably not a bad decision architecturally has proven inflexible and awkward. Where would you start with something like this? How would you approach the problem and what principals or design patters would you choose? Thank you very much


PHP email blasts using a cron job

My PHP application needs to send product expiry notifications to customers everyday. I am thinking of:   1. A one-time cron job for a php script that identifies the customers from a table of 10000 rows then send an email to each one using the SwiftMailer library. Each email will have unique content so I am not planning to do "batch send". * _Con: *_ Too slow and the server may kill it.   2. A recurring five-minute cron job that would send a definite number of emails (eg. 20) for every execution. * _Con: *_ All customers may not receive emails since the the queue may not finish within 24 hours. Please give alternatives and suggestions. TIA.


How to rewrite a TCP MMOG server designed to run in a single machine, in a distributed way?

I have a MMOG server running on C++, using winsockets. My server won't support more than 200 players. I had the idea of redesigning it so it will use multiple servers instead of one, so, maybe, for example, each server could take care of a number of players, and, if it was too laggy, it could transfer the responsability of that player to other server. I'm not sure of how to program a consistent game logic like that, though. Are there techniques for this?


How can you make a cluster run a task only once?

If you had a task that you wanted to run only once on a cluster of servers, at a regular interval what would be the best way of achieving this? _The definition of cluster in this case is 2 or more identical servers with distributed sessions sitting behind a load balancer._ **Use Case:** You have a task that is expensive to run that should only be run once per X hours. This job could for instance iterates over a bunch of records and updates their status.   * Worst case scenario is that having the job run twice invalidates your data.   * Best case scenario is that the job utilises resources on all your servers. **Requirements Summary:**   1. The job must still run even if one of the nodes are down.    2. The job must only be run once per schedule.   3. If multiple jobs are scheduled at the same time or at overlapping times that the number of running jobs is distributed equally between the servers.   4. The machines must have the same code base and be synchronised via NTP.   5. The configuration may differ between node and node, by environment variables.   6. The job has to start on time or within a given interval of the assigned time. (say 5 minutes for example) **Possible solutions**   * Set one node as the master node, this doesn't work as it violates 1 above.   * Make a request that the load balancer balances to kick off the job. Unfortunatly this has the side effect that if you have multiple jobs running at the same time they may all be run by the same machine. This would have to run in Java, in a servlet container. However it isn't coding the jobs I'm looking for. Surely this is a solved problem with known best solution. * * * **Related question.** Schedule job executes twice on cluster This isn't a duplicate as the solution is insufficient as per those 5 requirements given above. The most upvoted solution suffers from a race problem, and the second solution violates requirement 3


Help us with our git workflow

We have a web application that gets deployed to multiple regions around our state. An instance of the application for each region. We maintain a staging and production (master) branch in our repository, but we were wondering what is the best way of maintaining each instances codebase. It's similar at the core, but we have to give each region the ability to make specific requests that may not make it into the core of the application. Right now we have branches for each region, like region_one_staging, and region_one_production. At the rate we're growing we'll have hundreds of branches here in the next few years. Is there a better way to do this?


Should I open Source my iOS application?

I developed an iOS application as a student and I am currently distributing it for free in the app store. I have received a few enquires about adding features to the app including one person who would like the app to be open source so they can add features themselves. What concerns should I have if I open source my iOS application? Which open source license should I use?


DB Object passing between classes singleton, static or other?

So I'm designing a reporting system at work it's my first project written OOP and I'm stuck on the design choice for the DB class.   Obviously I only want to create one instance of the DB class per-session/user and then pass it to each of the classes that need it. What I don't know it what's best practice for implementing this. Currently I have code like the following:-               class db     {         private $user = 'USER';         private $pass = 'PASS';         private $tables = array( 'user','report', 'etc...');              function __construct(){             //SET UP CONNECTION AND TABLES         }     };          class report{     function __construct ($params = array(), $db, $user)      {                 //Error checking/handling trimed         //$db is the database object we created         $this->db = $db;              //$this->user is the user object for the logged in user         $this->user = $user;              $this->reportCreate();      }          public function setPermission($permissionId = 1)     {         //Note the $this->db is this the best practise solution?        $this->db->permission->find($permissionId)              //Note the $this->user is this the best practise solution?                 $this->user->checkPermission(1)              $data=array();         $this->db->reportpermission->insert($data)     }     };//end report      I've been reading about using static classes and have just come across Singletons (though these appear to be passé already?) so what's current best practice for doing this?


Outsourcing: question about code ownership and copyright

I want to ask a question from an employer point of view. I know that you are not really lawyers and stuff but I think you might help. I'm into negotiations with a freelancer (from India) to create a specific standalone application to do some file convertions. This is a program that I want to brand and resell. I got a good offer from them because they have already created such software in the past. But I'm having two issues: a) The program was previously made by them for another client of theirs, under unclear terms (or I haven't explicitly asked yet). From what they told me, they created the program for him for his private use. It seems that they still have copyright/ownership of the source code. b) They still want to keep the copyright/ownership of the code. I don't really mind, but in reality, I want to know how this can or can't affect me in the future. For example, what if the sales go well and suddenly they decide they want a piece of profit because the code is theirs? Something like that. Now another question: Is there a difference between the source code of a program and the compiled version of it? For example, I get the final product (as in an executable/installer) that I own and have the rights to, and they keep the rights for the underlying technology. Is this possible? And lastly, what do you think is the best to approach this? I think that I can allow them to keep the copyright of the code but sign a resell rights agreement to me for the final product. Is this valid at all? Can it be done?


Learning C# quickly (given I already know…)

Ok, I want to learn C# for a job interview (they want C# or Java, I know Java, but figure knowing both would be good). I already know Java, C++, C, F# and to some extent Python and Pascal. What are the big differences between C# and Java or C++? What are some good resources to look into, given I want to get a basic understanding in couple of hours? BTW: I told them that I didn't know C#, saying that I did however know these other languages, and that I could probably pick it up quite quickly.


Conversion of a number from Single precision floating point representation to a Half precision floating point

I have a code where I have to work on Half precision floating point representation numbers. To achieve that I have created my own C++ class fp16 with all operators(arithmetic logical, relational) related to this type overloaded with my custom functions, while using a Single precision floating point number with a Half precision floating point number. Half precision floating point = 1 Sign bit , 5 exponent bits , 10 significand bits = 16 bit Single precision floating point = 1 Sign bit, 8 exponent bits, 23 significand bits = 32 bits So what I do to convert from a Single precision floating point number to a Half precision floating point number:- For significand bits - I use truncation i.e. loose 13 bits from the 32 bits to get 10 bits significand for half precision float. What should I do to handle the exponent bits. How do I go from 8 exponent bits to 5 exponent bits? Any good reading material would help.


Software Methodologies

I'm very new in this area but I spend a long time to read about all this methodologies (SSADM, AGILE, RAD, SPIRAL, WATERFALL, INCREMENTAL, DSDM, XP, Iterative) in detail, how do they work, the advantageous and disadvantageous and ... Now the bad part part is: I understand them all separately but can't understand :   1. Is it like one of them let say **SSADM** ( WITH 5- 7 STAGES ) is what we try to achieve and we should use the rest (RAD, AGILE AND ..) to do so.   2. Or its like some of them are the main Categories like (SSADM, AGILE) and the rest becoming their subcategories?   3. Or no there are all separate things with no connections which in this case i can't understand stuff like this from Wikipedia: > SSADM is a waterfall method for the production of an Information System > design. SSADM can be thought to represent a pinnacle of the rigorous > document-led approach to system design, and contrasts with more contemporary > Rapid Application Development methods such as DSDM.


How can I explain this is an anti-pattern?

I recently started at a new job. The existing system works OK but is poorly designed and hard to maintain, and they are planning to rebuild it in MVC and I fear it will be much worse. (Not because of MVC) I want to discourage the lead dev from using an anti-pattern Existing issues include   * Hard coded strings in the business logic which are also tied to the interface (e.g. `if (x.CustomerType.Contains("Shipping Customer") foobar();` is _everywhere_   * Some classes map to dbTables directly (which is good). But because the software has to be "easy to add features to ", there is a Sharepoint-esque "DynamicData" table for storing new fields that the customer may require. a la `[FieldName] [FieldValue] [FieldType]`   * Refusal to use Linq but chains lamda queries for about 2 page widths.   * Exceptions not explicitly thrown or rethrown, but not handled properly (the client can see the call stack because it is just dumped into a popup dialog)   * Refusal to use `var` but loves the idea of `dynamic` everything.  What is the best way to go about convincing my lead dev to avoid these horrible methods and not put _everything_ in the generic key-value-pair table in version 2.0? (Considering I am new here and the team lead has been here for many years)


Left and Right most Derivation

So i understand the semantics of derivations as far as Backus Naur Form goes. One thing I cannot find in any text book or the various lecturers' notes that are on-line is this. When would a right most derivation be beneficial over a left most derivation? Would a compiler or generator always use either left, or right, or would it use both? So here's an example: Suppose we had the following language sentence: A = B + C * A Example Language Grammar Permitting the Above:               <assign>  <id> = <expr>      <id>  A | B | C     <expr>  <expr> + <term>             |<term>     <term> <term> * <factor>             |<factor>     <factor>  ( expr )             | <id>      Left Most Derivation:               <assign>   => <id> = <expr>                   => A = <expr> + <term>                   => A = <term> + <term>                     => A = <factor> + <term>                    => A = <id> + <term>                    => A = B + <term>                    => A = B + <term> * <factor>                   => A = B + <factor> * <factor>                   => A = B + <id> * <factor>                   => A = B + C * < term>                   => A = B + C * <factor>                   => A = B + C * <id>                   => A = B + C * A      Right Most Derivation:               <assign>  => <id> = <expr>           => <id> = <expr> + <term>           => <id> = <expr> + <term>   * <factor>           => <id> = <expr> + <term> * <id>           => <id> = <expr> + <term> * A           => <id> = <expr> + <factor> * A           => <id> = <expr> + <id> * A           => <id> = <expr> + C * A           => <id> = <term> + C * A           => <id> = <id> + C * A           => <id> = B + C * A           =>  A = B + C & C


Don't Repeat Yourself across integration-test code and production code?

I totally believe in not repeating yourself in production code. I've accepted the idea that you shouldn't repeat yourself within test code. But what happens when you have production services that would simplify test code? Let me pose an example. We have a service that accesses the Doohickey API. The Doohickey API is complex, by necessity, and we have a bunch of code to simplify it for our needs. Now I need to write some automated tests for our service. My tests need to set up data in the service and it would be really handy to reuse that facade. But then I get into an argument with myself, that goes roughly like this: "If you introduce a bug in the Facade, the test might not show it." "But, if you just take a copy, then when Dohickey Inc upgrade their API, you need to make the change in two places." "True, but maybe that's a good thing. We can upgrade production code first, manage test data using the old, known, still-supported API and test the new version thoroughly." And then I think maybe I'm overthinking the problem. Does anyone have experience with this kind of issue? If so, which way did you go, and did you regret it at all later? Edit: Early comments suggest a more specific example is required. Say I have a service that can create a product AND create an order. I have the following test to write ...               Given that product X exists     When customer Y orders product X     Then an order should exist for customer Y, including only product X      For the "When" part of this, I contact my service, which uses a facade around the Dohickey Purchasing API to create the order. The "Given" and "Then" steps should create a product and get an order, but they shouldn't go through the service to do so. Perhaps my service doesn't have that functionality, and if it does then I will test it elsewhere. BUT the facade that lives within the service would make the test code much simpler. So should I reference the production code and use it or copy / rewrite the facade?


Where is it permissible to add logging code in a MVC model?

Working on a C# WinForms program that is written in a MVC ( actually Model- View-Presenter) style and I want to add a few lines of code that is responsible for logging some events. Where should I write two or three lines of code that I need? Should I write it in the Presenter section? To get an idea, here is some lines of sample code that already exists in the **_Save()_** metohd in **_Company.MyApplication.Presenter.MyPresenter.cs class:_** he has written codes lie the following in this part of presenter:               private void Save(Helper.SaveStatusEnum status)     {         if (notification.CheckLocks(orderIdCollection))         {             using (new HourglassController())             {                 controller.FireActiveCellLeaving();                 ViewDocumentedValues();                      int result = saveController.Save(status);                      if (result == Helper.SAVE_SUCCESSFUL)                 {                     //  IS IT OK TO WRITE MY COUPLE LINES OF CODE IN HERE???????????                     model.Dirty = false;                          if ((model.CurrentStatus == Helper.OrderStatusEnum.Complete) || (model.CurrentStatus == Helper.OrderStatusEnum.Corrected))                     {                         controller.EnableDisableSheet(false);                     }                          CheckApplicationState();                     SheetHelper.ClearUnsavedDataRowImage(view.ActiveSheet);                 }                 else                 {                     MessageBox.Show("An unexpected error occuring trying to save.");                 }             }         }     }


Data structure for pattern matching

Let's say you have an input file with many entries like these:               date, ticker, open, high, low, close, <and some other values>      And you want to execute a pattern matching routine on the entries(rows) in that file, using a candlestick pattern, for example. (See, Doji) And that pattern can appear on any uniform time interval (let t = 1s, 5s, 10s, 1d, 7d, 2w, 2y, and so on...). Say a pattern matching routine can take an arbitrary number of rows to perform an analysis and contain an arbitrary number of subpatterns. In other words, some patterns may require 4 entries to operate on others may require more or less. Say also that the routine (may) later have to find and classify extrema (local and global maxima and minima as well as inflection points) for the ticker over a closed interval, for example, you could say that a cubic function (x^3) has the extrema on the interval [-1, 1]. (See link) Given that I don't know the size of the input file upon reading? What would be the most natural choice in terms of a data structure? What about an interface that conforms a `Ticker` object containing one row of data to a collection of `Ticker` so that an arbitrary pattern can be applied to the data. For example, let's say I have a pattern that requires `n` elements to form a match, I need to apply the pattern to those elements and then analyze each one of those chunks. What's the first thing that comes to mind? I chose a doubly-linked circular linked list that has the following methods:               push_front()     push_back()     pop_front()     pop_back()     [] //overloaded, can be used with negative parameters      But that data structure seems very clumsy, since so much pushing and popping is going on, I have to make a deep copy of the data structure before running an analysis on it. So, I don't know if I made my question very clear -- but the main points are:   1. What kind of data structures should be considered when analyzing sequential data points to conform to a pattern that does NOT require random access?   2. What kind of data structures should be considered when classifying extrema of a set of data points? * * * **Updated** Here's the main analyzer loop for my program (in some pseudocode that's a polyglot of a few languages)               data = new circular_linkedList()     // in my case, data is a circular linked list of elements.     foreach(element in dataFeed) {         data.push_front(element)     }          step_value = Pattern.numberRequiredElementsForMatch()     buffer = new circular_linkedList()     // at this point, you'll have a circular linked list     // where pop_back() will return the oldest entry and      // entry, and pop_front() will return the newest          // initialize the buffer     for(value in range(step_value()) {         buffer.push_back(data.pop_back())         // fill a buffer with the number of         // values required for a match.          // so now buffer will contain         // [elementk, ... , elementk+n]         // where buffer[0] < ... < buffer[n]     }     do {         last = buffer[len(buffer)]         ...         first = buffer[0]              Pattern.match(first, ... , last)         buffer.pop_front() // remove the first element         buffer.push_back(data.pop_back()) //add another element to the back               } while (!data.isEmpty())          ...      Anyway, that's a basic idea of what I have going on. The problem is that the way I'm doing it now, I have to reiterate through the loop to apply another pattern. (buffer sizes differ) It just seems inefficient to do that. Also, what happens when there's no more data in the buffer and it's not evenly divisible by the number of elements needed by a match?


Why do old programming languages continue to be revised?

This question _is not,_ "Why do people still use old programming languages?" I understand that quite well. In fact the two programming languages I know best are C and Scheme, both of which date back to the 70s. Recently I was reading about the changes in C99 and C11 versus C89 (which seems to still be the most-used version of C in practice and the version I learned from K&R). Looking around, it seems like every programming language in heavy use gets a new specification at least once per decade or so. Even Fortran is still getting new revisions, despite the fact that most people using it are still using FORTRAN 77. Contrast this with the approach of, say, the typesetting system TeX. In 1989, with the release of TeX 3.0, Donald Knuth declared that TeX was feature- complete and future releases would contain only bug fixes. Even beyond this, he has stated that upon his death, "all remaining bugs will become features" and absolutely no further updates will be made. Others are free to fork TeX and have done so, but the resulting systems are renamed to indicate that they are different from the official TeX. This is not because Knuth thinks TeX is perfect, but because he understands the value of a stable, predictable system that will do the same thing in fifty years that it does now. Why do most programming language designers not follow the same principle? Of course, when a language is relatively new, it makes sense that it will go through a period of rapid change before settling down. And no one can really object to minor changes that don't do much more than codify existing pseudo- standards or correct unintended readings. But when a language still seems to need improvement after ten or twenty years, why not just fork it or start over, rather than try to change what is already in use? If some people really want to do object-oriented programming in Fortran, why not create "Objective Fortran" for that purpose, and leave Fortran itself alone? I suppose one could say that, regardless of future revisions, C89 is already a standard and nothing stops people from continuing to use it. This is sort of true, but connotations do have consequences. GCC will, in pedantic mode, warn about syntax that is either deprecated or has a subtly different meaning in C99, which means C89 programmers can't just totally ignore the new standard. So there must be some benefit in C99 that is sufficient to impose this overhead on everyone who uses the language. This is a real question, not an invitation to argue. Obviously I do have an opinion on this, but at the moment I'm just trying to understand why this isn't just how things are done already. I suppose the question is: > What are the (real or perceived) advantages of updating a language standard, > as opposed to creating a new language based on the old?


Is doctrine 2 fast enough?

I need to build a social network that is expecting very high traffic, 10k - 50k + registrations in a day, not even including visitors, pageviews, image uploads, etc..., a lot of database activity. We have a solid quad core dedicated server right now with 8GB ddr3 and 2tb hdd sata. Will doctrine be to slow as far as queries and load time to handle such a high traffic website?


How can I apply Six Sigma in a software development environment?

I am a Java developer, but I was asked to learn about applying Six Sigma with the goal of increasing our organization's profits. I have read that Six Sigma can be applied in all environments, but I'm interested in the nuances of applying it to software development. Which concepts of Six Sigma can be applied to a software development environment and how can I effectively apply them? Are there any resources that discuss Six Sigma being applied specifically within a software development environment?


Practical Use of Depency Injection (IoC) Container

I am creating a MVC-ish framework in PHP. I am trying to implement a DI Container to allow the creation of controller objects (among others). My MVC framework is pretty typical. Each module (or component if you wish) has a controller responsible for executing requests. These module controllers typically extend a base `Controller` class. All controllers will accept `Request` and `Response` objects as arguments. The confusion occurs because some controllers may need different arguments in order to function. For example: Many controllers will need a `Database` object; Controllers which send mail may need a `Mailer` object; while a controller which logs data may need a `Log` object. The DI Container will contain the recipes for creating all these controllers. My front controller needs to be able create any of these controller objects, as specified by a request. Furthermore, each controller needs to be able to create any other controller. **How do I get my front controller and module controllers to access the DI Container in a way that doesn't result in a dependency on the DI Container by each controller?** I actually don't mind if the front controller is dependent on the container, I am more concerned about the module controllers. Thanks,


How can I hide confidential data in my open source project?

I have an open source project that uploads files to DropBox among several file hosts. Right now I am screen scraping for DropBox. To use their API, I have to hardcode a SECRET KEY provided by them to me for OAuth authentication. But I'm afraid that the key won't be secret if it is visible plainly for anyone to see. It is 'possible' for someone malicious to use my key to upload a virus to a user's account (who already allowed access to my app) that will spread to their pc (if they had desktop sync enabled) and to others' pc (if they had shared folders) and so on. :O I found this unanswered question that has the same problem as mine. But I would like to know generally how one would hide confidential data in an open source project. I have one idea.   * Have a placeholder in the source code like "<SECRET KEY HERE>" and fill it only when building binary for release? (yuck!) Any decent idea?


What is 'Asp.net Handler'?

I read in a book 'beginning asp.net 4.5 in c#' that when some one type the URL of the asp.net website, the browser send the request to the server and if the server find any ASP.NET markup or controls then it will leave this or map this to something called asp.net handler. So, what is it this handler? Is it the server itself or another thing in the server?


Extreme Programming Daily Commits

Isn't daily commits (committing all changes before going home) an XP practice? What are the benefits of following this? What are the risks of not following this?


The modern way to perform error handling...

I've been pondering this problem for a while now and find myself continually finding caveats and contradictions, so I'm hoping someone can produce a conclusion to the following: ### Favour exceptions over error codes As far as I'm aware, from working in the industry for four years, reading books and blogs, etc. the current best practice for handling errors is to throw exceptions, rather than returning error codes (not necessarily an error code, but a type representing an error). But - to me this seems to contradict... ### Coding to interfaces, not implementations We code to interfaces or abstractions to reduce coupling. We don't know, or want to know, the specific type and implementation of an interface. So how can we possibly know what exceptions we should be looking to catch? The implementation could throw 10 different exceptions, or it could throw none. When we catch an exception surely we're making assumptions about the implementation? Unless - the interface has... ### Exception specifications Some languages allow developers to state that certain methods throw certain exceptions (Java for example, uses the `throws` keyword.) From the calling code's point of view this seems fine - we know explicitly which exceptions we might need to catch. But - this seems to suggest a... ### Leaky abstraction Why should an interface specify which exceptions can be thrown? What if the implementation doesn't need to throw an exception, or needs to throw other exceptions? There's no way, at an interface level, to know which exceptions an implementation may want to throw. So... ### To conclude Why are exceptions preferred when they seem (in my eyes) to contradict software best practices? And, if error codes are so bad (and I don't need to be sold on the vices of error codes), is there another alternative? What is the current (or soon to be) state of the art for error handling that meets the requirements of best practices as outlined above, but doesn't rely on calling code checking the return value of error codes?


Cost of setInterval in Javascript

I've got some code that I want to run when certain HTML elements are added to the page.   To do this, I have a "runOnRender" function:               runOnRender: function (func, args, interval) {                 var that = this;                 var guid = hb.getGuid().substr(0,7);                      var checkFunc = function () {                     if (that.$el.height() > 0 && that.$el.width() > 0) {                         clearInterval(that[guid]);                         that[guid] = 0;                         func.call(that, args);                     }                 };                      this[guid] = setInterval(checkFunc, interval || 200);             }      Setting the interval to 200 is about as high as I can go before there is often a noticeable lag in the event firing. The last thing I want is my users wondering why a button just got clicked or seeing a label text change, etc. Here's the catch. It is entirely possible that this "runOnRender" will be set up.....but the User never causes the action that makes the HTML element in question hit the DOM....which means that this code would just keep infinitely running as long as the page is open. I'm on a nice, powerful, dev machine....so I'm wondering what the cost of this code is and whether there is a better way.


Programming Languages "Higher Level" Than Python

In general, I have been presented with these sorts of heirarchies for programming language abstraction: Assembly < C < C++ < Java < Python where C abstracts less than C++ and so on. You could also consider this on a compiled vs translated vs interpreted language basis (which is usually how this topic is considered, putting C and C++ together), but I'd like to think in terms of levels of abstraction for this question. Lisp dialects, my favourite language, seem to vary on implementation and fit in between these, along with languages like Haskell and Prolog, but languages like Ruby and Python are undoubtedly at the top. Are there languages that abstract even more significantly than Python or Ruby? Are these languages desirable to use? Having started with Lisp/C++, I was not expecting to so thoroughly enjoy Python and Ruby. I was also not expecting them to make my coding so much better, since you can use features like Scipy's Weave to use Python to do high level computation for most things and then low level computation for bottleneck code. So I'm wondering if there are even higher level languages available of which I'm unaware and that I should try out.


Would this violate any copyright issues?

I am currently publishing a paper on skin detection. However, I need to find the appropriate histogram bin size for each colorspace. I recently came upon a paper that published what it found to be the ideal bin size. The paper can be found at: http://www.inf.pucrs.br/~pinho/CG/Trabalhos/DetectaPele/Artigos/OPTIMUM%20COLOR%20SPACES%20FOR%20SKIN%20DETECTION.pdf. I am specifically talking about Table 1. If I cite the source, would it be okay for me to use data from the table? Note that I cannot contact the author of the paper.


What is the preferred Internet media type of a RESTful POST request?

Is there a preferred/recommended Internet Media Type for RESTful POST requests? For example, if I want to add a new user, should I send the data as a URL encoded string like:               name=Foo&otherData=Bar      or does REST recommend I send the data as whatever format the response is going to be sent as (e.g. JSON/XML)?               <user>       <name>Foo</name>       <other-data>Bar</other-data>     </user>


why create mobile applications for web oriented programms, if it's just possible to use websites?

There are a lot frameworks on the market who wrap actual websites into mobileapps. I found myself thinking about the question - why is it needed to create mobileapps if it's possible to just having mobile version of the site?


Is this considered an implementation of the Template Method design pattern?

Please consider a `StringBank` class. This class holds a list of Strings and can `return` them to the client. It's code (irrelevant stuff omitted):               abstract class StringBank{              List<String> strings;              public List<String> getStrings(){                  for(String string : strings){                 if(!stringValid(string)){                     strings.remove(string);                 }             }                  return strings;              }              public abstract boolean stringValid(String s);          }      As you can see, `stringValid` is an abstract method, meant to be implemented by the subclasses. This way subclasses serve as 'filters' of the string bank, filtering out invalid strings (e.g. a particular subclass may return `false` for strings that end with an 'a'). My question is: is this considered an implementation of the Template Method design pattern? The purpose of Template Method is to define steps of an algorithm in an abstract superclass, and have the subclasses define the implementation of some of these steps. Usually, the 'template method' - where the algorithm is defined, would look something like this:               void algorithm(){         step1(); // implemented in this class         step2(); // implemented in this class         step3(); // abstract method, implemented in subclasses.         step4(); // implemented in this class     }      However in `StringBank`, the algorithm is very simple, so it only involves one method call: `stringValid()`. The rest of the steps of the algorithm are defined in the method itself (looping through the strings, removing strings and returning them). **`getStrings()` doesn't really 'look like' a 'template method', so I'm not sure if this is considered a Template Method pattern implementation.** The algorithm could be described as:   1. For each string: 1.1. Check if valid. _(implemented by the subclasses)_. 1.2. If invalid, remove from list.   2. Return list of strings. Would you define the implementation I described as an implementation of the Template Method design pattern, even though `getStrings()` doesn't 'feel' like a classic template method?


Do you use unit tests at work? What benefits do you get from them?

I had planned to study and apply unit testing to my code, but after talking with my colleagues, some of them suggested to me that it's not necessary and it has a very little benefit. They also claim that only a few companies actually do unit testing with production software. I am curious how people have applied unit testing at work and what benefits they are getting from using them, e.g., better code quality, reduced development time in the long term, etc.


validating APIs

We have a series of hardware and we have decided on a common API to be given to the customer for use. The customer will use this API in order to program the hardware. The API includes functions for establishing a connection with the h/w like X_Open,X_Close,X_SetConfig, X_GetConfig, no of hardware connected, error handling with the corresponding structs to be filled by the API or the customer. The hardware will ofcourse be validated independently also. What strategies can I use to validate this API ? We want to test this API i.e it works as expected for instance we are actually able to setConfig in the h/w or get no of devices on the bus or if the API function X_Open is called , the function is able to establish a connection to the hardware as expected or say API function X_GetNoDevices returns no. of present devices on the bus. We want to validate that all API functions work as described to the customer


How to design an algorithm-heavy and object-light application

Other than vertices, edges, faces and meshes, my geometry processing project/application has only about half a dozen other entities such as curves on surfaces. However the majority of my code is dedicated to geometry processing. Being a naive programmer when I started this project, I implemented the various geometry processing algorithms as methods of the few classes that I had. As a result, some of my classes are now very large because they implement geometry processing algorithms (and therefore span up to 5 *.cpp files) -- very bad. In some cases I also implemented the algorithms as classes in their own rights. As such I now have classes that are not really entities. I now have a problem with this because I now believe that classes should be instantiable entities, and their methods the things that they do. Yet following this rule has led to large files. At the same time deviating from it has led to classes that do not make sense as instantiable entities e.g. a Geodesic class. Anyway I'm planning a redesign of this project and I'd appreciate advise on how to deign my classes. One of the options I've considered is to implement each algorithms as a collection of methods in a namespace. However as namespaces do not have instance variables, there will be lots of argument passing between the methods -- again not very nice.


Change my way of thinking in preparation for functional programming

When switching to a functional style of programming after coming from procedural and OOP, what things do I need to know upfront about "this new way of thinking"? How do you prepare yourself for diving in the FP world and get it first time around? What are the basics to learn and set straight first?


What's the best lesson you have learned in your career?

I think mine is "there's no such thing as a five minute job" - that programmers tend to be overly optimistic about development and that we should really think through a the implications before promising a quick solution to a problem and then diving in to code


Is it worth evaluating compiler optimization on trivial cases?

I'm currently testing Visual C++ 10 on some trivial pieces of code. For example, like this one (taken from here):               int main()     {         int i;         clrscr();         for(i=0,i++,i<=5;i++,i<=2;i=0,i<=5,i+=3){             printf("%d ",i);         }         return 0;     }      For the code above the compiler emits machine code that in effect does this:               clrscr();     printf("%d ",2);     return 0;      and this makes me happy. Sometimes the compiler emits really dumb code and then I file a Microsoft Connect feedback item. I have the following concern. Is testing a compiler on trivial code worth it? On one hand, we want real code to be compiled as good as possible, not some stupid sample snippets. On the other hand, compiler optimization is recursive in sense that if code B follows code A and the compiler can see that code B does nothing it can eliminate code B and eliminate whatever connected A and B logically and thus optimize (and maybe eliminate) code A better. And if the compiler fails to optimize away code B it will likely not be able to optimize code A either. So every improvement of generated code matters - better code at some point can mean better code elsewhere and this is beneficial. Is it worth testing compilers on trivial samples or are only tests on "real code" worthy?


Bogarting the Data Access Layer

Situation: The dba is an offsite contractor who keeps the entire DAL code checked out in TFS. It would be nice as the front end developer to be able to add columns, and tweak procs and whatnot, without having to rely on waiting for this dude to respond to your emails to do the work. Question: What would be a recommended solution/process that would allow for more rapid/agile development, while maintaining data integrity as well as peace love and happiness among the team?


Dynamic method creation in python

I have a class that will have a number of external methods that will all call the same smaller set of internal methods. So something like: obj.method_one(a, c) and obj.method_two(a, c) where obj.method_one calls obj._internal_method(a, c, y) and obj.method_two calls obj._internal_method(a, c, z). They're nearly identical but they have one argument at the end that differs on the internal call (which is a constant). I could just copy and paste a few times but I was wondering if theres any way to dynamically create these external methods.


I cant get myself to sit down and start coding

I spent the last 5 months working my regular job (qa) and developing an android application in the evenings. Now we were in two week vacation for Christmas and I spent the whole time developing my application and now I feel exhausted, I just cant get myself to sit down and start writing code again. It just feels like a huge mountain of weight that I have to lift, even thinking about it. Is this normal? Will this get worse with time? Im in the IT industry for 9 months now, 6 of them, like I said were very intensive. 25 year old. Also, I think its important to mention that I learn extremely fast and intensively and I get ahead of myself all the time. Am I going to burn my potential off? PS: Why would someone downvote my question? what wrong or bad have I done? Which rule have I not obeyed?


What is the best way to do offline failover of a desktop based client that uses a web service?

I have three incoming projects that share a common problem: > they need to have the logic on a web system and they need a local > application (e.g. point of sale) that communicates with such system through > a RESTful web service. ### My Solution The solution I managed to come up with is to implement in the desktop application message queuing to store operations while the service is offline, more precisely, asynchronous message queuing. However, that is the easy part (if such is the best solution). I'm also concerned with data syncing and conflict resolution. The main system needs to be web based since a web app is required for reports and monitoring by the stakeholders, and the web services would handle requests for several establishments. The desktop clients (preferably thin) will be implemented with Java (more specifically Netbeans) and the web system with Symfony2. Two of the projects require hardware integration for the client, so making the desktop application with web technology (e.g. Appcelerator Titanium) could be a major pain. ### My Question   1. What is a better solution that scales, meaning maximum efficiency with minimum effort (and preferably no additional costs, like buying a backup server for local operation) ?   2. Who else has dealt with this before? How did you solve your problem? What lessons can you share?   3. How did you deal with synchronization?  **Edit: Added a missing part to my question in point #3**


What is Mozilla's new release management strategy?

I saw today that FireFox released a new version (5). I tried reading about what was added and ran into this link: http://arstechnica.com/open- source/news/2011/06/firefox-5-released-arrives-only-three-months-after- firefox-4.ars It states that: > Mozilla has launched Firefox 5, a new version of the popular open source Web > browser. This is the first update that Mozilla has issued since adopting a > **new release management strategy** that has drastically shortened the > Firefox development cycle. I find this very intriguing - any idea what this new strategy is?


Application connecting to database server

I'm working on an application which requires user credentials and so on. So a database is required on the backend. What is the best practice to connect to a database without hardcoding your password into it? The program could be reverse engineered and one might get the password which is something we obviously don't want.


Data service API design

We're designing a data service that will store a large number of statistics about stocks, including historical data. The client will be a web application, which will need to pull various bits of data to show in different places on the site. Since the different places need to show different sets of statistics, it's not sensible for the service to simply offer one method which retrieves all the data that we have. Since there are so many different types of statistics, the service isn't aware of the type of each one and simply stores them by key. We previously tried to deal with this by having a number of methods which would return data objects with varying levels of detail, for example getBasicStockInfo, getStockInfo, getFeaturedStockInfo, getStockDetails. The trouble I found with this was that it became tedious to add new items of data to the objects (need to change server code), and each one would get bloated over time as fields are added for some specific locations on the front end. On the other hand, it would be impractical to have a method for each location on the front end that returns the specific data that's needed in that location. Does anyone have any ideas of how best to handle this situation? One thing I'm considering is that the client would have to send a list of data keys for the data it wanted, and would get back a map of the statistics. I'm not sure if this is the way to go though, as the weight of parameters would get pretty heavy with the same ones being passed repeatedly from each location in the web app.


What's the best practice to do SOA exception handling?

Here's some interesting debate going on between me and my colleague when coming to handle SOA exceptions: On one side, I support what Juval Lowy said in Programming WCF Services 3rd Edition: > As stated at the beginning of this chapter, it is a common illusion that > clients care about errors or have anything meaningful to do when they occur. > Any attempt to bake such capabilities into the client creates an inordinate > degree of coupling between the client and the object, raising serious design > questions. How could the client possibly know more about the error than the > service, unless it is tightly coupled to it? What if the error originated > several layers below the service—should the client be coupled to those > lowlevel layers? Should the client try the call again? How often and how > frequently? Should the client inform the user of the error? Is there a user? > By having all service exceptions be indistinguishable from one another, WCF > decouples the client from the service. The less the client knows about what > happened on the service side, the more decoupled the interaction will be. On the other side, here's what my colleague suggest: > I believe it’s simply incorrect, as it does not align with best practices in > building a service oriented architecture and it ignores the general idea > that there are problems that users are able to recover from, such as not > keying a value correctly. If we considered only systems exceptions, perhaps > this idea holds, but systems exceptions are only part of the exception > domain. User recoverable exceptions are the other part of the domain and are > likely to happen on a regular basis. I believe the correct way to build a > service oriented architecture is to map user recoverable situations to > checked exceptions, then to marshall each checked exception back to the > client as a unique exception that client application programmers are able to > handle appropriately. Marshall all runtime exceptions back to the client as > a system exception, along with the stack trace so that it is easy to > troubleshoot the root cause. I'd like to know what you think about this.


GPL and OpenJDK: Questions regarding source headers

I have some legal questions regarding OpenJDKs source header:               /*      * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.      * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.      *      * This code is free software; you can redistribute it and/or modify it      * under the terms of the GNU General Public License version 2 only, as      * published by the Free Software Foundation.  Oracle designates this      * particular file as subject to the "Classpath" exception as provided      * by Oracle in the LICENSE file that accompanied this code.     (...)        * Is it GPL-conform to define a comment-part of a source-file (in this case the header) as "must not be modified"?    * Do other GPL-licensed open-source projects derived from this sources need to obey this "statement"?   * Does Oracle really have a Copyright on these GPL-sources?   * Is it GPL-conform to state that it's **_only_** allowed to `modify [the software] under the terms of the GNU General Public License version 2`?   * What does this mean for GPLv3 open-source projects which are using these (possibly modified) sources?   * Do I have to fear editing (and publishing) this file (and maybe adding something to the file header) in my own GPLv3 open-source project?


Use Objective-C protocols like Java interfaces

I'm a Java developer moving to Objective-C. So far in Objective-C I've seen protocols used extensively to implement the delegate pattern, but I haven't seen then to add a layer of abstraction in the way one would use Java interfaces. My gut instinct is to use protocols to define a contract and add a layer of abstraction, so that I may later substitute a different concrete class. Is this idiomatic in Objective-C, or do people tend to just use `@interface` to define the contract for a concrete class and use it directly?


Do I have the wrong idea about software engineering?

Hello folks I have a question which's been raised by my latest job (rather intern). Just to put things into context - I'm 21 and I've finished my 2nd year of university before that I've had around 2 years of experience doing sys admin/QA jobs and basically I can say that I've seen how different IT sectors operated. Flash forward to present times and here's me landing an interning job at one of the premier research institution in the UK. What I have to do is create some internal tools using a mix of technologies - mainly AWS/Java/Bash - you get the picture. Everything is OK, I'm doing my job BUT I'm not happy. Why is that - because I'm expected to work in an ad-hoc matter. That is create things quickly, without spending time on designing. My manager explicitly said that it was expected to "rush" through problems as they arise and we essentially. As a consequence it turned out that things had to be re-done and re-engineer and they are still not perfect. As far as testing is concerned - keep it to a minimum, as long as it looks working then it is OK. Am I at fault to disagree with this way of conducting work? Is it wrong to want to think over the system as a whole, then focus on different components and see how they might inter-operate, to zero in on different "key points" which might turn out to be problematic in the future? Is it a crime to want to do a good job and not a "quick job"? Is it a mistake or wrong attitude to want to research the data structures applicable to a problem so that you can choose the best depending on a particular problem set? To the best of my understanding the "Engineering" bit in "Software Engineering" has got to do exactly with this - research your problem domain and come up with a informed solution then refine as necessary? I've been to an interview at an Arm's office in the UK and they showed me their SCRUM room and it looked they had pretty good idea as to how to manage their project - they had a backlog, they had metrics as to how long each issue might take to resolve - the usual things for SCRUM - completely different than the way things are run "here" Have I built a wrong idea about the software industry in general? I'd like to hear your input on that. I mean I "entered" software development purely because I want to create things - plain and simple, but I want to create quality things. I want to see my software used in various scenarios, I want to see it bullet proof - isn't that the driving force for all software engineers? I think everyone can be a programmer/coder by just learning the syntax but for me where the real fun begins is when you actually have to come up with a design which is doable in real world. I used to do my university assignments by just looking at them and directly start coding and could easily get marks above 75% and never really appreciated the "software development lifecycle" module. But now when I saw in the real world how bad it is to work without any formal process and the frustration that is inherent in situation where you don't know if the requirements are going to change tomorrow (oh, did I say that we don't have clearly defined requirement analysis?) I really like to believe I just landed a position where some people just needed a code monkey to do their dirty work and this is not the case how the software world operates at large.


Class Naming Conundrum

I am working on a personal project that works with databases, and in this project I have a set of classes that are _similar_ , so they inherit from a common base class. The problem I am faced with is that I have this nagging feeling that the names of the classes that derive from the base class do not really reflect what they actually are. Caveat: Please ignore the fact that this looks like a reinvention of the wheel. That's the point of the project. The common base class is called Entity. Its purpose is to serve as the base for:   1. Classes that describe the data returned by a SQL query or stored procedure, or    2. Classes that describe a SQL query or stored procedure and their parameters. Both of these classes are created by consumers of the assembly to describe the stored procedures and queries in their database, and the data they will retrieve from it. For example, these are designed to work against the Northwind database:               public class Employee : DataEntity     {         public int EmployeeId { get; set; }         public string LastName { get; set; }         public string FirstName { get; set; }     }          [Sql(@"SELECT [EmployeeId], [LastName], [FirstName]             FROM [Employees]             ORDER BY [LastName], [FirstName]")     public class SelectEmployee : SqlEntity     {         public int EmployeeId { get; set; }     }      As it stands, I am currently calling the first of these Data Entities, and the second SQL Entities. However, I am not entirely sure that these are fitting terms. For instance, are they actually _models_? Is there a better term that I am not considering? The assembly only considers public properties that have both a getter and a setter. The developer can add anything else to it if he or she needs to. So a Data Entity can be extended to include additional functionality. Any advice would be greatly appreciated. **EDIT** It's worth noting that you can also model stored procedures with this stuff (again, using a Northwind database stored procedure):               [Sql()]     public class CustOrderHist     {         [Parameter("@CustomerId", SqlDbType = SqlDbType.NChar, MaxLength = 5)]         public string CustomerId { get; set; }     }      The assembly automatically binds classes to stored procedures, and properties to parameters.


Where can I get free public raw data?

_In web development, a mashup is a web page or application that uses and **combines data** , presentation or functionality from two or more sources to create new services._ There are many sources for getting data (raw information). Governments are good examples.   However many of those cost and have complicated licensing. For instance SMHI in Sweden sells temperature data meanwhile our neighbor country Norway gives it away for free. One would say what kind of application are you building and what data do you need? I would say give me some interesting data and I will do a good mashup of it. I could just plot it on Google maps for instance. So the question is: **Where can I get free data?** Note: I'm not interested in data mining using a webcrawler! Please share your sources with me.


What to look for in someone to provide short-term cover for a lone developer?

Our intranet is running an in house developed ASP.NET application. In our team I am the only technical person so this means my role is everything from development to server administration to "the printer isn't working". In a couple of months once a major rewrite is finished I am taking a couple of weeks holiday and we need to get someone in to cover for this period. I am at a loss of what skill set we should be looking for to cover over a short term. Being a major upgrade there will of course be bugs, though it will be up long enough to deal with any that are particularly worrisome and/or common. From this point of view I'm thinking that given the short timescales getting in a developer would be the wrong choice (small bugs can wait, big bad bugs that area left would likely be the sort that experience and time to learn the system would be needed to fix, I am of course insisting on a laptop and VPN to deal with this if it happens). Looking this way I'm thinking that someone with server administration skills would be the preferable route (able to keep the servers up if they go down, restart services if needed etc), though it still leaves a lot of leeway in the specifics to look for. Also despite the above opinion on getting a developer, being able to look through the code to pinpoint where a bug is interacting with the servers could of course be useful. Half the problem is of course that there's lots to cover with nothing in particular standing out as the big area to focus on. Here's a breakdown of what we have, any advice or ideas would be greatly appreciated.   * In house ASP MVC2 application, includes some custom JavaScript on the front end   * Legacy ASP Classic (some areas of the intranet that aren't yet upgraded, running in tandem with the MVC application)   * Mediawiki install running on Apache and MySql on Windows   * Servers are running Windows 2008 and SQL2008   * Powershell backup scripts   * Simple C# reverse proxy (the intranet uses Windows authentication, we allow an external organisation access to the intranet so this proxy acts as their gateway and authenticates as a known generic user)


Is argument or parameter considered more appropriate for a function/method argument/parameter?

Hopefully the topic is not too confusing, I am curious though as lately I have seen more and more use of the word parameter to denote a function's passed in values, whereas during my studies I feel as if argument was used almost exclusively. Is parameter more appropriate as argument is more specific to a programs arguments specific at runtime whereas when a function is called, the values passed to it are parameters to the function itself? From a curious programmer.


Methodology behind fetching large XML data sets in pieces

I am working on an HTTP Server in Delphi which simply sends back a custom XML dataset. I am not following any type of standard formatting, such as SOAP. I have the system working seamlessly, except one small flaw: When I have a very large dataset to send back to the client, it might take up to 2 minutes for all the data to be transferred. The HTTP Server I'm building is essentially an XML Data based API around a database, implementing the common business rule - therefore, the requests are specific to the data behind the system. When, for example, I fetch a large set of product data, I would like to break this down and send it back piece by piece. However, a single HTTP request calls for a single response. I can't necessarily keep feeding the client with multiple different XML packets unless the client explicitly requests it. I don't have any session management, but rather an API Key. I know if I had sessions, I could keep-alive a dataset temporarily for a client, and they could request bits and pieces of it. However, without session management, I would have to execute the SQL query multiple times (for each chunk of data), and in the mean-time, if that data changes, the "pages" might get messed up, therefore causing items to show on the wrong pages, after navigating to a different page. So how is this commonly handled? What's the methodology behind breaking down a large XML dataset into chunks to save the load?


Is thıs code efficient always for finding array[max]?

I am trying to find max value of an array, firstly i am shorting my array min to max after that i am using array[array.length-1] Is this logic efficient in large arrays?               public static int findMax(int[] array){              Arrays.sort(array);              int max = array[array.length-1];              return max;     }//end method


How should XML subtree manipulation be handled in a public API?

I'm working on an API whereby a specific call would replace a subtree of an XML document—rooted at some element—with another subtree. The two options I'm considering for a response to this call are:   * Return the DOM   * Return the modified subtree In the interests of developing a standardized, stable API, I'd like to get this right. Is there a best way to handle this type of scenario? What are the benefits and drawbacks of doing it one way over the other? Would it make sense to offer both these options to API consumers?


Sending Data to a Specific Android Device

I am planning an application that includes a membership card functionality, where the user can place an order, either in the application or by phoning the vendor. Once the order is placed, especially in the case of a phone in order, what would be the best approach to having the vendor side communicate relevant details to a specific device. I have looked Android's C2DM, that doesn't seem to be the best method. I don't want to send messages/data to all devices with the application installed, only the specific device that placed the order.