title: Can a function be too short?

text: Whenever I find myself writing the same logic more than once, I usually stick it in a function so there is only one place in my application I have to maintain that logic. A side effect is that I sometimes end up with one or two line functions such as:               function conditionMet(){        return x == condition;     }      OR               function runCallback(callback){        if($.isFunction(callback))          callback();     }      Is this lazy or a bad practice? I only ask because this results in a greater number of function calls for very tiny pieces of logic.


title: What is the preferred object to store this type of data structure

text: I was in a conversation with someone who codes for me. He was frustrated with my approach to a particular problem. I am entirely self taught and very pragmatic - I am not a professional developer instead I sometimes write code to get something done and then pass it on to him to clean it up - make it robust etc. We are reading in large txt files that use sgml tags to mark boundaries between individual documents that are related to one another.               <opentagfor txt file>     <document>     <maybe some attribute tags of the document>     the     document     could be a uuencoded     could be html     or something else     can tell what type by the attribute tags     </document>     <anotherdocument>     <maybe some attribute tags of the another document>     the     document itself     could be a uuencoded     could be html     or something else     can tell what type by the attribute tags     </anotherdocument>      .      .      .           <closetagfor txt file>      The individual documents get consumed downstream. Sometimes they get written out to a file structure for indexing, other times some of their content is extracted and saved as 'data'. So my approach was to create a dictionary of dictionaries.                document_dictionary = {document_position_index:{attribute-tag-1:value1,attribute-tag-2:value2,document:the\n    document itself\n    could be a uuencoded\n    could be html\n   or something else \n  can tell what type by the attribute tags}, . . .}      document_position_index is the index position of the document in the original txt source file - has no relevant meaning at all. now if I want to do something with the documents I can do things like               for document in document_dictionary         if document['some-attribute-tag'] == someValue:             do something      The problem is this bad coding (specifically using an integer (document_position_index)) was frustrating to my developer. He said that it is bad form. I still after Googling for a while do not understand. So I would appreciate either a better explanation then I got from him or some pointer to the right direction. Is this the type of question that should be asked here?


title: Making Modular, Reusable and Loosely Coupled MVC Components

text: I am building MVC3 application and need some general guidelines on how to manage complex client side interaction between my components. Here is my definition of one component in general way: Component which has it's own controller, model and view. All of the component's logic is placed inside these three parts and component is sort of "standalone", it contains it's own form, data needed for interaction, updates itself with Ajax and so on. Beside this internal logic and behavior of the component, it needs to be able to "Talk" to the outside world. By this I mean it should provide data and events (sort of) so when this component gets embedded in pages can notify other components which then can update based on the current state and data. I have an idea to use client ViewModel (in java-script) which would hookup all relevant components on page and control interaction between them. This would make components reusable, modular - independent of the context in which they are used. How would you do this, I am a bit stuck as I do not know if this is a good approach and there is a technical possibility to achieve this using java- script/jquery. The confusing part is about update via Ajax, how to ensure that component is properly linked to ViewModel when component is Ajax updated (or even worse removed or dynamically added). Also, how should this ViewModel be constructed and which technicalities to use here and in components to work as synergy??? On the web, I have found the various examples of the similar approach, but they are oversimplified (even for dummies) or over specific and do not provide valuable resource or general solution for this kind of implementation. If you have some serious examples it would be, also, very helpful. Note: My aim is to make interactions between many components on the same page simpler and more robust and elegant.


title: What are examples of automating BDD specifications through the UI layer?

text: I understand it is better **to automate BDD specifications below the user interface** whenever possible. For example and quoting from Gojko Adzic's book: _Specification by Example_ : > Don't check business logic through the user interface My question is then: **_What are the specific use cases when using the UI layer does make sense in the context of BDD?_**


title: ActiveX, OLE, COM explanation or informative links

text: I've been programming a lot with C# on Visual Studio and many minor/other languages, but I'm having a really hard time to get the grasp of ActiveX, OLE, COM interfaces. All I got is that they're like dll, you can write something in a language and make it work on another. Searching here but found nothing, searched on google but I found only hardcore explanation of people assuming it's the easiest thing in the world and building explanation on the assumption you already know what they are, giving just a line or two of explanation about them. I really need to know what's better now (as I've seen on wikipedia ActiveX it's the evolution of both COM and OLE which are older standards...) and a full blown explanation of them, possibly with code in it. In C# and Visual studio it's all much easier. You can create dll and include them in your project without much effort... Please explain here or paste links here with all the explanations you know/can find... Thanks


title: Any experience with Mono on production servers?

text: I am curios to use .NET for some web applications (e.g. ASP.NET MVC 2). However my budget is limited so I would like to use Mono on Linux. I have never used Mono before, and I haven't read about any bigger sites that is using Mono+Linux on the server in production. What's your experience using Mono on Linux in production? How is the performance and stability compared to .NET on Windows Server? Is there any popular sites that is using it in production? Any articles available online were they share their experiences?


title: Quick algorithm to find matches between two arrays

text: I'm faced with the following problem: I have an array which is produced by the parsing of a yaml file which contains patterns in the following structure.               "Programming books"         Title:               a list of titles         Author:     "Art Books"         Title:               foo               bar         Author:               Mrs. Foo               Mr. Bar         Year:      the program is supposed to be given random input and find if there is a book with that particular Title,Author and Year. So far I'm using the following                foreach book_type,values from config{            tag_match = 0            foreach tag from values{                 tag_no = values.length()                 foreach value from tag{                      if value in input                           tag_match++                 }           }           if tag_match == values.length()                /* tag the book matched continue matching*/      }      The program is not supposed to receive many matching lines bu it is supposed to receive a huge amount of data. So far it has to do book_type.length() * tag.length() * value.length() iterations for each line of input, is there a better way to do this?


title: Where to place configuration files sources

text: I am developing a C# windows service application, which have different configuration files for development, for production system, for test system, like:               Dev.config     Test.config     Prod.config      Now we are using SVN version control system, and configuration files stored in projects directories:               -trunk       -MyFooService         -Configs           Dev.config           Test.config           Prod.config       -MyFooService2         -Configs           Dev.config           Test.config           Prod.config      Prior publishing service to production you should get respective configuration file from that folders. How do you think, it is correct? Or configuration files should be placed in another repository? Or in another folder or should not be placed in VCS? Or may be it will be better to place files like that:               -trunk       -src         -MyFooService         -MyFooService2       -configs         -MyFooService           -Configs             Dev.config             Test.config             Prod.config         -MyFooService2           -Configs             Dev.config             Test.config             Prod.config


title: Post-hoc testing in TDD recommended?

text: I have a personal project that doesn't have robust testing. I had a bit of TDD going on at the beginning, but it quickly became counterproductive as the project details changed dramatically over time. So a lot of previously written tests have become useless. Now that the project solidified a bit, I dont' think big changes are likely. Should I go back and rewrite those tests for old functionalities or just start fresh and write tests for new functionalities only?


title: What is needed to become a Software Engineer?

text: I obtained a BSc CS & Applied Mathematics November last year and started working as a Software Developer in December. I'm currently working for a very solid company and I'm part of a small core development team, developing big software. I absolutely love software development and would someday like to become a (Senior) Software Engineer, Systems Analyst or Solutions Architect (not 100% sure about all the senior titles). My questions is - what experience do I need to obtain to achieve this? What is the necessary/desired career path? What type of courses do I need to attend to gain the needed knowledge?


title: What are the pros and cons of the MVVM architecture?

text: In class today we were introduced to the MVVM architecture for Silverlight/WinPhone/WPF; it looks nice for big projects, but what are your thoughts on MVVM? What are the pros and cons? I want to get more into the architecture so that I know when I should use it.


title: what is the transferability of changes in terms of a GPL license

text: I have a program that is offered to the public on the web as a GPL program. This is a hobby type project that i stated 3.5 years ago and i have had one collaborator for most of that duration who has contributed some code me and my collaborator both like to see the program develop as it's both our hobbies. A person has adopted its game board to a play against the computer program. He wrote his own engine and his game he plays on the board uses a different set of rules. I think both me and my collaborator are ok with a more permissive licence grant. I've told the the derived work author that code he modifies he can add his copyright, and any java files that are all his code he can have sole copyright. I can grant a more permissive grant. But if i do what would his right of transferability be. By granting him a modification of gpl and he makes his code open source, could he in turn give the same grant to anyone else or does he not have a right of transferability? The first question (that would cause the second to be not applicable) is: would GPL work for what i'm doing to promote my brand and allow others somewhat permissive use. The secondary question is would my lack of enforcement or accepting modifications of terms be inherited by any users of his work. My open source software is in a hobby area, chess. Understanding the open source licences helps me be persuasive and helps with communication as the eventual adapters of code begin.


title: How do you control code quality on your team?

text: Here is my situation. After almost 2 years I was able to convince my boss to use TDD, version control, coding standards for the entire team and a MVC framework for our web projects. I was finally there. It should be heaven but it's ending up like hell. I prepared some material about MVC and code samples showing common unit tests. Showed to the team, explained how things should be done and got their support. It seemed all fine, after all, team members were very experienced. I also made sure that the members had time to do things. At first, writing tests can take a very long time. So I tried to make them comfortable with "losing" this time without any manager asking them to do things quickly and dirty. After 15 days I was doing the first review of the code. And the result was not good. I found business logic on controllers and on views and the tests folder were almost empty How do you deal with these kind of things? Do you recommend any tools that can help me on code review or this is something that I have to do manually? I'm using PHP with Zend Framework.


title: How to design a good receipt number

text: I am developing a web application, this application will need to generate receipt number for every confirmed transaction. What is a good receipt number? I think a receipt number should not be just a running number generated by database, but it should have some meaning beyond just a unique running number. Here is what I have come up with so far,               Format: EYY-ddd-XXXXXXX     Example output: E13-146-0000001      Where: `E` : It is just a to signify this receipt number was generated by my system. This value is always `E`. `YY` : Is the current year the receipt was generated, so in this case it is `13` `ddd` : Is the day of the year, `146` is May 26 (in 2013). `XXXXXXX` : Is a 7 digit running number, up to 9,999,999 So my system can generate up to 10 million unique receipt numbers daily until 2099. What do you think? Is this sensible? Any suggestion is appreciated. **Update** Judging from the comments so far, it looks like there is no specific 'pattern' or 'best practices' for receipt number. My intention in asking the question is to know whether there is specific best practises in generating the number that I should know about. Looks like I am free to use whatever pattern I feel sensible. Other requirements   * As short as possible (that is why I didnt go for YYYYMMdd-XXXXXXX)   * Somewhat not to obvious (YYYMMdd is way to obvious).   * Should be fixed length. (Easier to detect if customer entered invalid receipt number)   * Can generate fairly large numbers (10 million a day seems sensible, though I doubt my system will be that popular)   * Can be made into QR code (so staff can scan and verify the number is valid)   * Someone mentions about **error detection code like ISBN** , seems good but I havent read it yet.


title: View Source - is the Viewable markup important to you?

text: I just read a very compelling blog post from Scott Hanselman where he quoted colleague Erik Meijer as follows: > JavaScript is an assembly language. The JavaScript + HTML generate is like a > .NET assembly. The browser can execute it, but no human should really care > what’s there. - Erik Meijer He goes on to give examples of how some of today's biggest sites (the one he shows is from Google+, but cites also Bing, Facebook, etc.) are producing sites where when you do a "View Source", you will see a lot of tight "minified javascript". Essentially, unreadable on the surface. Simply put, you cannot go into a site and look at their source and see a pretty formatted version of the markup. My question to you is similar to what Hanselman asks: is that important to you? If it works, is that good enough? In my opinion, YES - results are what matters - Google is an example of that. But I must admit, as a developer, it is nice to have the ability to, once in a while, look at the source and get ideas and examples from sites I admire. Your thoughts?...


title: Issue when Return Message is a collection of objects (Sequence Diagram)

text: I have a sequence diagram for the following operation. The Activity class uses method present in ActivityBL class. The method is: GetActivities(ActivitySearch objt) The result message is a collection of Activity objects. (Colletion in C#). How do we represent the return message in the sequence diagram? At present, I am listing it as message containing only one Activity object. How to represent it as a collection? ![enter image description here](http://i.stack.imgur.com/9Sja7.gif)


title: What is the name of a grammar which can change its tokenizer in mid parse?

text: I was creating a language and discovered that my language tokenizer would have to change depending where in the parse it is. I.e. `abc[1]` would be parsed as 4 tokens (`abc`, `[`, `1`, `]`), where as `{ abc[1] }` would be parsed as 3 (`{`, `abc[1]`, `}`). Is a grammar that would change its tokenizer mid parse defined somewhere? Does a grammar even define such a thing or is it irrelevant to the grammar and is just not really done on a parser level?


title: About anonymous objects

text: In Java particularly Android development, is there any difference between declaring an object like               SomeObject object = new SomeObject();     someField.setObject(object);      compared to an anonymous object (not sure if that's what is called)               someField.setObject(new SomeObject());      performance wise? Or improvements in memory. Thanks.


title: How do "You Ain't Gonna Need it" and "Now is better than never" play together?

text: I often find myself embracing "now is better than never" when I'm advancing the DRYness of a design. Typically, I find that I need to cultivate an understanding of the One Authoritative Location for a piece of knowledge in the context of a system of other pieces of knowledge. Thus, I tend to design the system 'now.' Conversely, this practice causes me to build fairly far in advance, despite a reasonable chance that I ain't Gonna Need It. How do these two patterns square up? What practices do you use to ensure that they play nice? How do you teach them together without creating confusion?


title: Passing variables from PHP to C++

text: I need to call a program from PHP and pass some vars and/or sets of key-value pairs to it. How do I pass these vars, through arguments to the called function? `exec("/path/to/program flag1 flag2 [key1=A,key2=B]");` Or is there a better method to achieve this? Somebody suggested to me to write them into a txt file and pass the path to it to as an argument instead, `exec("/path/to/program path_to_txt_file);` but I’m not to excited about this method.


title: Why are cons lists associated with functional programming?

text: I have noticed that most functional languages employ a singly-linked list (a "cons" list) as their most fundamental list types. Examples include CLisp, Haskell and F#. This is different to mainstream languages, where the native list types are arrays. Why is that? For CLisp (being dynamically typed) I get the idea that the cons is general enough to also be the base of lists, trees, etc. This might be a tiny reason. For statically typed languages, though, I can't find a good reasoning, I can even find counter-arguments:   * Functional style encourages immutability, so the linked list's ease of insertion is less of an advantage,   * Functional style encourages immutability, so also data sharing; an array is easier to share "partially" than a linked list,   * You could do pattern matching on a regular array just as well, and even better (you could easily fold from right to left for example),   * On top of that you get random access for free,   * And (a practical advantage) if the language is statically typed, you can employ a regular memory layout and get a speed boost from the cache. So why prefer linked lists?


title: Do first-class methods exist?

text: Okay, I know first-class functions are cool, closures even better, etc. But is there any language with first-class methods? In my mind, I see a first-class method as an "object" that has both a function pointer and a pointer to a specific instance of the class/object, but the implementation doesn't matter. I just want to know if there is _any_ language that uses them. And as a bonus, how were they implemented?


title: How agile methodologies can be applied in a typical " services " company?

text: My company is a custom software services company for external clientes, which means our typical project is one in which the contract already states the full budget of the project. Our typical project starts by defining requirements (improving the proposal high-level requirements), then we code the project, test it and ship it. We have an acceptance phase were the client tests the software and in that phase we can usually implement small changes asked by the client, or we charge extra for change requests. In some projects we have intermediate releases so the clients can check the progress of the project and give feedback on it. In summary: something like waterfall... I've followed the "agile" movement for a bit now and I always see it being a good match for a "product" company, or a company building software for an internal client. But are there good stories / advantages on using agile methods in my kind of company/projects? What are your experiences, what do you think about this?


What do people in IT consulting firms do? Ok I can guess they _consult_ , provide answers to questions, but exactly what kind of questions do they answer that it is even possible people will pay enough for them to sustain their company expenses?


title: Should I use Dependency Injection or static factories?

text: When designing a system I am often faced with the problem of having a bunch of modules (logging, database acces, etc) being used by the other modules. The question is, how do I go about providing these components to other components. Two answers seem possible dependency injection or using the factory pattern. However both seem wrong:   * Factories make testing a pain and don't allow easy swapping of implementations. They also don't make dependencies apparent (e.g. you're examining a method, oblivious to the fact that it calls a method that calls a method that calls a method that uses a database).   * Dependecy injection massively swells constructor argument lists and it smears some aspects all over your code. Typical situation is where constructors of more than half classes look like this `(....., LoggingProvider l, DbSessionProvider db, ExceptionFactory d, UserSession sess, Descriptions d)` Here's a typical situation I have a problem with: I have exception classes, which use error descriptions loaded from the database, using a query which has parameter of user language setting, which is in user session object. So to create a new Exception I need a description, which requires a database session and the user session. So I'm doomed to dragging all these objects across all my methods just in case I might need to throw an exception. How do I tackle such a problem??


title: Why we use virtual and override keywords in c#

text: Can anyone explain me what's the point of overriding base class implementations (if its not abstract), because it's not ethical move to modify features of the parent class according to the wishes of derived classes. The best way is to make the base classes abstract and carry on the inheritance chain. Whereas when designing a class hierarchy initially we gather or elicit all the essential requirements/features that should be belonged to a base class. Therefore, in a middle of a project we do not need to change base class implementations. According to my knowledge, base class implementation should be a constant. Thus, under this aspect, there's no real use of "override" keyword in c#. If it's not so please explain me with an example.


title: Future of a ServiceStack based Solution in the Context of Licensing

text: I just want someone to clarify the following questions as Demis Bellot had announced a couple of weeks ago that ServiceStack would go commercial. Refer link below. https://plus.google.com/app/basic/stream/z12tfvoackvnx1xzd04cfrirpvybu1nje54 (Please note that when I say ServiceStack or SS I refer to all associated SS libraries such as ServiceStack.Text, etc.)   1. If I have a solution already developed using ServiceStack today will I have to purchase a license once SS goes commercial even if I don't upgrade the SS binaries to the commercial release version?   2. Will previous versions of SS (prior to commercial licensing) always be opensource and use the same license as before?   3. If I fork SS today (prior to commercial licensing) on Github, would it be illegal to maintain that after SS goes commercial?   4. If the answer to question 2 is yes, then would I still be able to fork a previous version after SS goes commercial without worrying about the commercial license (all the while maintaining and releasing the source to the public)?


title: Is MultiTasking in a development environment worthwhile?

text: If we get assigned to do multiple works simultaneosly, is it good for growth for a developer? If there is a development project and if you are assigned to work on a maintenance project as well, is it good for the growth or will it inhibit the progress?


title: Saving critical data in (third party) databases

text: How do you save important(privacy-wise) user data like SSN, Credit Card Numbers and Addresses in databases? **Scenario:**   Only data which needs to be available is saved. For eg, SSN is saved because the app uses the SSN to identify a particular record. or credit card details are saved to make 1-click transactions possible.Some such data can be encrypted and saved, but some data needs to be available in plain text(eg. for full text search). The app uses third party hosting. **Questions:**   How secure is such data in plain text(or otherwise) on third party hosts like HostGator or App Engine? Do you save such data on third party hosts(and is this practice recommended)? Do you store it in plain text or do you encrypt such data? Should only those companies who have the resources to have their own servers proceed to build such apps?


title: How to represent a Rubik's Cube in a data structure

text: If I am attempting to simulate a Rubik's Cube, how would you create a data structure to store the cube's state in memory, with X number of tiles per side? Things to consider:   * the cube can be of any size   * it is a Rubik's cube, so layers can be rotated


title: In Search of Automatic ORM with REST interface

text: I have this wish that so far Google hasn't been able to fulfill. I want to find a package (ideally in PHP, because I know PHP, but I guess that's not a hard requirement) that you point at a database, it builds an ORM based on what it finds there, and exposes a REST interface over the web. Everything I've found in my searches requires a bunch of code--like, it wants you to build the classes for it, but it'll handle the REST request routing. Or it does database and relational stuff just fine, but you have to build your own methods for all the CRUD actions. That's dumb. REST is well defined. If I wanted to re-invent the wheel, I totally could, but I don't want to. Isn't there somebody who's built a one- shot super-simple auto-RESTing web service package?


title: Should injecting dependencies be done in the ctor or per method?

text: Consider:               public class CtorInjectionExample     {         public CtorInjectionExample(ISomeRepository SomeRepositoryIn, IOtherRepository OtherRepositoryIn)         {             this._someRepository = SomeRepositoryIn;             this._otherRepository = OtherRepositoryIn;         }              public void SomeMethod()         {             //use this._someRepository         }              public void OtherMethod()         {             //use this._otherRepository         }     }      against:               public class MethodInjectionExample     {         public MethodInjectionExample()         {         }              public void SomeMethod(ISomeRepository SomeRepositoryIn)         {             //use SomeRepositoryIn         }              public void OtherMethod(IOtherRepository OtherRepositoryIn)         {             //use OtherRepositoryIn         }     }      While Ctor injection makes extension difficult (any code calling the ctor will need updating when new dependencies are added), and method level injection seems to remain more encapsulated from the class level dependency and I can't find any other arguments for/against these approaches. Is there a definitive approach to take for injection? (N.B. I have searched for information on this and tried to make this question objective.)


title: Is something like coderunner possible on PC?

text: I'd give my firstborn's left arm for something like this http://krillapps.com/coderunner/ Yes, I know, executing unknown code may be hazardous to your health, but I'm quite capable of reading some code before I run it


title: Concurrent development w/o central design?

text: I've got a team of developers which are trying to write specifications/tests concurrently for different (and sometimes adjacent) parts of the system. Typically, the person writing the specification/test is **not** the developer who will write the implementation and make the specification/test pass. Here's the problem we're having: the person _receiving_ the specification/test for which an implementation hasn't yet been written isn't familiar enough with the design of the system's many objects to know: _Do I solve this problem (the specification/test) with an existing object(s), or do I create (for the first time) the dependencies which will allow the system to pass this specification/test?_ Not all of the developers on the project have the domain knowledge to make these decisions _well_ , and we're colliding so far as disparate designs and objects created in relative isolation begin to conflict and duplicate each other. What is the solution(s) to this problem? Is it simply inescapable that every developer in the project must know (or be prepared to ask) the system's objects? Feel free to provide what you think are obvious answers.


title: To go for scjp 6(now ocp jp 6) or oca jp 7?

text: I have been preparing for scjp 6 since 2 weeks. Now I came to know about the OCA JP 7 and OCP JP 7 exams. Should I start preparing for OCA JP 7 or go ahead with OCP JP 6(formaly scjp 6)? Also I am currently referring SCJP 6 by Sierra and Bates.


title: How long can it take for a screen to appear before it's considered a performance issue?

text: I am involved with the development of a Windows application that has various screens. One of them takes ten seconds to appear with no spinner or other indication that the screen is loading. I consider this a serious performance issue but I seem to be the only one who is concerned. Am I being overzealous? What is an acceptable amount of time to wait for a screen to appear?


title: Where should the description about branches in a VCS be stored?

text: If you maintain many branches in your favorite version control system it is essential understand which branch for which indented. In SVN you can put _README_ on same level as trunk/branches/features dirs. How about DVCS? You can maintain _ChangeLog_. But with this approach it is hard get breif view that done in all branches (if you maintain different long lived releases changelogs between them they can be slightly different). In open source project info about branches usually can be found on project wiki, so stored separately from VCS. I think this is bad thing. When you clone project you also need aceess to wikis.


title: Does LaTeX have a future outside of CS?

text: _with emphasis on outside of cs science students & staff_ In the "good ol' days" LaTeX was **it** ; mainly because of two reasons, first - it gave such a better quality document that nothing else came close, and second - there was pretty much nothing else as a valid alternative. _I'm talking 1985-1995 here._ And because of that, a major part of technical (or medicine, biochems., ... which have a logical way of thinking in them) users (people in general, in those professions) used it for their documents. It wasn't too hard to learn, and gave excellent results. Nowadays, however, _things are a changin_ , as old Dylan would put it. MS Word** for example as the most common one, is giving _quite a nice_ result, with a much higher gain/pain ratio. For most people, it is _good enough_. If one wants to create a document for which there is no LaTeX template, pros start to weight even more on Word's side. So, the question is this - do you think /and why - argument it/ LaTeX & co. has a future outside of cs sciences world (which users are inclined towards programming, and therefore usually take in LaTeX structure naturally, or at least with much less effort) given the recent trends? ** insert your favourite word processor; MS Word was taken just as an example p.s. This was inspired by one other question that came about recently, but also with the trend I noticed recently, but which has been going for a while now (past few years) that even technical magazines, which used to demand articles in TeX, now ask for them in .doc format (or ...).


title: Why it is `(cons 1 (cons 2 (cons 3 nil)))` and not `(cons 3 (cons 2 (cons 1 nil)))` for [1,2,3]?

text: Is there any special reason that to construct list in Scheme you use               (cons 1 (cons 2 (cons 3 nil)))      instead of               (cons 3 (cons 2 (cons 1 nil)))      ? While the first seems more obvious because it **reads** in the right order, the second is the one which actually **reduces** in the right order. Also, it seems more natural to construct a list starting with nil and adding elements to it, not the opposite. I've also found the latter has properties such as being very curry friendly: `(cons 1)` nicely becomes `a function that appends 1 to a list`.


title: What defines a good developer from an employer’s perspective?

text: Suppose the company who the developer starts at is a cooperative, team of 10-15 members. The company follows SDLC.   * **What qualities do you think an employer seeks in a developer?**   * **You are welcome to explain why the quality is important from employer’s point of view.** Here are some examples:   * Analytic / Logical / Critical / Questioning / Methodical   * Team player   * Responsible    * Social   * Problem solver


title: What features would you like to have in PHP?

text: Since it's the holiday season now and everybody's making wishes, I wonder - which language features you would wish PHP would have added? I am interested in some practical suggestions/wishes for the language. By practical I mean:   1. Something that can be practically done (not: "I wish PHP would guess what my code means and fix bugs for me" or "I wish any code would execute under 5ms")   2. Something that doesn't require changing PHP into another language (not: "I wish they'd drop $ signs and use space instead of braces" or "I wish PHP were compiled, statically typed and had # in it's name")   3. Something that would not require breaking all the existing code (not: "Let's rename 500 functions and change parameter order for them")   4. Something that _does_ change the language or some interesting aspect of it (not: "I wish there was extension to support for XYZ protocol" or "I wish bug #12345 were finally fixed")   5. Something that is more than a rant (not: "I wish PHP wouldn't suck so badly") Anybody has any good wishes? Mod edit: Stanislav Malyshev is a core PHP developer.


title: Architecture design with MyBatis mappers

text: I am creating rest web service for providing data. I am using Spring MVC for handling rest requests, and MyBatis for data access. Application should be designed in the way that it should be easy to change the data access implementation (for example to hibernate or something else) and it has to be fast (so I am trying to avoid unnecessary overcomplication of design). Now my question is about the general design of layers. I would normally use DAO interface and then different implementations for different data access strategies, but MyBatis uses interfaces to access the data. So I can think of 2 possible models but I am not sure which one is better or if there is any other nice way:   1. Controller layer - uses Service layer interfaces     * services are then implemented for each data access stretegy - for example for mybatis:     * service implementation uses Mapper classes to access data and do whatever it needs to do with them and sends them to controller layer   2. Controller layer - uses Service layer - service layer uses DAO interfaces     * DAOs are then implemented for each data access strategy - for example for mybatis:     * DAO class uses mapper interface to access data and sends them to service layer, service layer then do whatever it needs to do with them and sends them to controller layer I prefer the first strategy as it seems to be less complicated, but then I would have to write all of the service code for another data access again. What do you think? Thank You


title: Lending epub files for limited time to users

text: I am looking for components to build a digital library who lends people epub (ebooks) for about a week. It's like a digital version of the offline old public library. Now I have found several flash (pdf) file streaming solutions. But that would require an active internet link. And like the public library, you are able to take your books to the beach or pool on holiday abroad where you have no connection. So streaming is no option. The other file restriction method I have found was DRM, but that would require a really expensive license of Adobe Content Server 4 which is not suitable for my little hobby project. But it seems that adobe content server and Adobe Digital Editions is the only option at the moment. Or are there open source alternatives?


title: Create ASP.NET input forms from XSD?

text: I have several types of XML document. The format of (i.e. the elements in) each document type is defined in an XSD. Is there a convenient way to create HTML elements (or ASP.NET controls) on an ASP.NET form, to display/edit the elements in (contents of) an XML document, given the XML document and/or the document's XSD definition as input? Within the XML/XSD:   * Complex (i.e. parent) elements may contain sub-elements   * Simple elements are of type 'string', 'integer', 'list of string values', etc.: which should map to corresponding HTML input elements   * Elements are documented (labelled) using `<xs:annotation>` in the XSD (these would be suitable HTML `<label>` elements for the corresponding `<input>` elements).   * Each element is required, not required, and/or there may be several of them, specified using `minOccurs` and `maxOccurs` in the XSD As well as generating the ASP.NET form, when the user posts the completed form, the software should read the returned data and pack it into an XML document. How to do this? I can write software to parse the XSD and generate the forms myself but that seems like a lot of code to write in-house and maintain.


title: Is there a proper way to create a file format?

text: I'm building a proprietary file format for an application I wrote in C# .NET to store save information and perhaps down the line project assets. Is there a standard on how to do this in any way? I was simply going to `Serialize` my objects into binary and create a header that would tell me how to parse the file. Is this a bad approach?


title: Apply vs. Ok buttons

text: Often when configuring settings, applications have both an "Apply" and an "Ok" button. Should the "Ok" button always perform the "Apply" before closing the window out? Are there pros and cons to doing this?


title: Why do I need unit tests for testing repository methods?

text: I need to play devils advocate on this question a bit because I cannot defend it well because of lack of experience. Here is the deal, I get _conceptually_ the differences between unit testing and integration testing. When specifically focusing in on persistence methods and the repository, a unit test would use a mock possibly via a framework like Moq to assert that say an order searched for was returned as expected. Let's say I have built the following unit test:               [TestMethod]     public void GetOrderByIDTest()     {        //Uses Moq for dependency for getting order to make sure         //ID I set up in 'Arrange' is same one returned to test in 'Assertion'     }      So if I set up `OrderIdExpected = 5` and my mock object returns `5` as the ID my test will pass. I get it. I _unit tested_ the code to make sure what my code preforms returns the expected object and ID and not something else. The argument I will get is this: > "Why not just skip the unit tests and do integration tests? It's testing the > database stored procedure **and** your code together that's important. It > seems like too much extra work to have unit tests and integration tests when > ultimately I want to know if the database calls and the code work. I know > the tests take longer, but they have to be run and tested regardless so it > seems pointless to me to have both. Just test against what matters." I could defend it with a text book definition like: "Well that's an _integration test_ and we need to test the code separately as a unit test and, yada, yada, yada..." This is a case where a purist explanation of practices vs. reality is loosing out. I run into this sometimes and if I can't defend the reasoning behind unit testing code that ultimately relies on external dependencies, than I can't make a case for it. Any help on this question is greatly appreciated, thanks!


title: Command line merge conflict tools

text: I sometimes prefer to work in a terminal. I use git, and sometimes have merge conflicts. Are there any merge-conflict-resolution tools that work in a command-line only environment?


title: Drawing shapes dynamically on an image through web browser

text: We have a scenario where we create floor plans of locations when we visit. The floor plan is finally shown on the web. It's come to the point now where we want to show floor plans but have a key with various items on them, when an item on the key is clicked, the image should highlight all the areas of the floorplan that have that specific item. I guess we're looking for some sort of open standard javascript lib to deal with SVG (has to work pre IE9 so pure SVG wont cut it) and the floor plans have to be able to be created through a .net application to be deployed on the web. I'd rather stay away from flash if at all possible to be honest. Below are a few conceptual images of what we're trying to achieve. ![enter image description here](http://i.stack.imgur.com/gUBpc.png) ![enter image description here](http://i.stack.imgur.com/pGbCh.png) ![enter image description here](http://i.stack.imgur.com/ectLN.png)


title: In-memory DB to perform intersects on set slices

text: I have a specific programming need where I need to efficiently store large sorted sets in memory, query them for ranges, and intersect them against other sets that are also queried for ranged. I am looking at Redis, but I can't see a range slice command. MongoDB can only use 1 index, so it has to perform row-level scans, whereas I wish to process using columns that are intersected. I'm also looking at Counchbase, but can't easily determine from the documentation if it is suited to this. I know it uses Memcached, which is AFAIK not suited to this usage. Could anyone share potential solutions for this specific problem? **EDIT** For example, I need to perform the following: Get the IDs of all cars where the price is between 2000 and 3000, and intersect that will all cars where the engine capacity is between 3000 and 4000.


title: var args constructors/methods vs lists

text: In the long debate of using arrays vs lists in the public API of Java classes, I tend to prefer lists in most situations. However, I also found convenient to use var arguments in many constructors and methods, which require declaring an argument of the method (the last one) as an array (implicitly adding "..." before the parameter name). Since in many of these methods I do want to provide a programmer the possibility to _either_ explicitly list the arguments (with var args) or use a pre-defined collection when invoking the method, I often end up defining a constructor or method with var arguments, and an overloaded version that accepts a list instead of the var args array. For example:               public void myMethod(X ...items) {           myMethod(Arrays.asList(items));     }            private void myMethod(List<X> items) {           ...       }        I know that in theory I do not need to overload the method replacing the var args array with a list if I want the programmer to send a collection of objects. He could just send an array. The reason I often do this is because most (if not all) of the methods in my API use lists instead of arrays, and it is a bit weird that for one or two methods requirying collection of objects, the programmer needs to work with arrays (in cases when the var args are not convenient). So I provide an overloaded version working with list for consistency. However, since this is a recurrent problem, I have the uncomfortable feeling of being writing boilerplate code too often. I would like to receive feedback if my motivation of keeping my interface consistent (accepting var arrays or lists, but not forcing the programmer to work with arrays if not really required) is valid enough to keep writing overloaded versions using lists for most of my methods requirying var arguments. I would like to highlight that I know that for certain methods arrays could be more convenient than lists. My question concerns situations where the only motivation for declaring the last argument of the method as an array is because in certain scenarios using var arguments can be convinient. **UPDATE** Thanks for your feedback. My conclusions at the moment are the following:   * Reduce the usage of var args as much as possible.   * Continue adding an overloaded version of the method with var args, such as the array argument is replaced by a list (or an `Iterable`, as @Kevin pointed out), in cases where it can be useful to have the choice to invoke the method with either var args or with a collection.   * Stop using Java as soon as possible :) (I already knew that one)


Shouldn't storage classes be taught early in a C class or book? I notice that a lot of books, even some of the better ones, covert it toward and end of the book and some books just add it as an appendix. I would teach it together with variables. This is so foundational and I think unfortunately many do not make it that far in a book. Now that auto has a different meaning (vs being optional) it may confuse people that didn't realize it has always been there. for example: C Programming: A Modern Approach 18.2 Storage Classes 401 Properties of Variables 401 The auto Storage Class 402 The static Storage Class 403 The extern Storage Class 404 The register Storage Class 405 The Storage Class of a Function 406 Summary 407 @DeadMG, I fear I didn't state my question properly. Everyone always uses storage classes. Every single variable in a C program has a storage class. The thing is that some of the keywords were made optional because, for example, `int i; = auto int i;` The reason I ask is because I've seen code so bad where variables are declared at the top of a program to be made available to a function and not lose its value when it goes out of scope but only one function needed it. Then, by default the variable's storage class is "extern" int i; but they may not know since extern is assumed by the compiler. What they should have done is to declare it in the function that needed it as static, static int varToKeepValue; that way you achieve the desired goal of preserving the variable's value when the function goes out of scope throughout the execution of the program, while also making the code more readable. btw: I'm interested in this, please email me your thoughts if this question gets closed. On another note: you have a very odd approach... keep learners ignorant? I think is because they don't have that information that the language is not used properly. It's not like not letting kids run with knives. My approach is, learn the language inside and out that will let you use it properly.


title: What capabilities of Adobe Flash are not present in the WinRT API?

text: As from March 2013, Microsoft allows Adobe Flash content to play by default on its immersive Internet Explorer 10: http://redmondmag.com/articles/2013/03/11/new-ie-10-flash-policy.aspx When asked about Silverlight, Microsoft says > Silverlight will not be supported in immersive Internet Explorer 10 since > these capabilities are superseded by the new WinRT API. Does this mean that there are capabilities of Adobe Flash not present in the WinRT API that forced Microsoft to allow Flash? What are these capabilities?


title: How does Github calculate language percentage in a repo?

text: I have a repo with Ruby and PHP code in it. Github says my repo is 74.8% PHP and 25.2% Ruby I do not understand how this can be. When I compare the 2 languages in my project:               # Count how many files:          # Ruby     ls | grep ".*\.rb" | wc -l     # returns 10          #PHP     ls | grep ".*\.php" | wc -l     # returns 1               # Count how many lines, words, chars:          # Ruby     cat *.rb | wc     # returns 229, 812, 5303          # PHP     cat *.php | wc     # returns 102, 473, 2760      Ruby always seems to have more. Am I missing something?


title: Environment Variables and Visual Studio 2012

text: I have a problem with Visual Studio 2012 and Environment Variables under Windows 7. I added a variable called `{LIBS}` with the value `C:/libs/`. In `C:/libs/` are folders containing C++ libraries. So far, so good. I added the paths to the project's settings (linker etc.), like `{$LIBS}boost` to include the boost libraries. I expected that I would now be able to use something like this               #include "boost/someboostfile"      but this does not work, I have to use the absolute path               #include "../../boost/someboostfile      but this is what I do not want to do. Is there anything I'm doing wrong?


title: How to avoid binary dependency on size change

text: class A { public: int i; }; // A.h and defined in project libA.vcxproj (libA.dll)      I'm using class A in multiple places at various projects as below. Apporoximately 100 projects.               include "A.h"     class UseA { public: A *a; UseA(){ a = new A(); } ~UseA() {delete a;} }      My problem is whenever I add a member variable to class A I will have to build all the projects (~100) as the size of the class A has been changed and building 100 project is time consuming. How to avoid building so many projects on size change of a single class? Also I have many classes like class A defined in libA.vcxproj.


title: When is it appropriate to use colour in a command-line application?

text: Currently I have a command-line application in C called `btcwatch`. It has a `-C` option that it can receive as an argument that compares the current price of Bitcoin with a price that was stored beforehand with `-S`. Example output with this option is:               $ btcwatch -vC  # -v = verbose     buy: UP $ 32.000000 USD (100.000000 -> 132.000000)     sell: UP $ 16.000000 USD (100.000000 -> 116.000000)      The dilemma is whether to use colour for the `UP` or `DOWN` string (green and red, respectively). Most command-line applications I know of (apart from git) stay away from colour in their output. In my desire for `btcwatch` to look and be quite "standard" (use of `getopt`, Makefiles, etc), I'm not sure if colour would look out of place in this situation.


title: is it possible to use shopify for just their shopping cart component or should I just roll my own

text: I'm working on an e-commerce site and am a rails developer; due to the nature of the items, I am managing them in their own database so I'm really looking for something that is only for the shopping cart aspect (there are things like heavy nesting and integration with other pieces of the app that would be very difficult to reproduce). It seems like there are two ways that I can go. (1) One way is rolling my own shopping cart and using something like Stripe (which I have been evaluating and am working fine with it). This literally could be as easy as creating an orders table and a line items table and a lot of front-end. (2) Or I could try to integrate into a third-party shopping cart like Shopify. I am not really sure if I can just use the shopify shopping cart or whether there is any advantage to this. If I already have most of my app done, would shopify (or another shopping cart app) provide any significant benefit (it clearly could)? Or would the integration be too much of a headache? Like for example, when a user 'adds to order' on my site, can I post to shopify and associate it with that user? thx


title: The Programmers Bill of Responsibilities

text: So, we've all heard of The Programmers Bill of Rights and XP has a similar concept. It's a common complaint these days that we hear a lot about people's rights but not so much about their responsibilities, so what should be on the programmers bill of responsibilities. That is things that they should do, which they may find unpalatable, but that which separate programmers acting professionally and responsibly, from those who do not. I'm primarily interested in the unpalatable ones and the ones which tend not to happen. That is the ones that programmers tend to shirk and avoid, rather than the ones which 90% of programmers actually want to do (such as always refactor and use source control). So, **what should be on the Programmers Bill of Responsibilities?**


title: Do you actually write 'clean code'?

text: I have seen some programmers tweaking their code over and over again not only to make it 'work good', but also to make it 'look good'. IMO, 'clean code' is actually a compliment indicating your code is elegant, perfectly understandable and maintainable. And the difference comes out when you have to choose between an aesthetically appealing code vs. code that's stressful to look at. So, how many of you actually write 'clean code'? Is it a good practice? What are the other benefits or drawbacks of this?


title: Find all lines segments intersections

text: I have a collection of lines segments, represented by an array. Ex: [3,7,13,6,9] is 4 line segments: [(3,7)(7,13)] , [(7,13)(13,6)] , [(13,6)(6,9)] , ([6,9)(9,3)] ![enter image description here](http://i.stack.imgur.com/vv0FK.png) I want to find all the lines segments intersections(not including the common point), is there any better way of doing it rather than brute force(Checking all the options with O(N^2))?


title: What is the best way to lead a team of 4-5 students for a summer project?

text: We're a bunch(4-5) of 3nd year college students about to begin our 3 months summer vacation and we would like to get going on a project. We want to make a game with XNA, it doesn't have to be big or something but we have 3 months so I'm not sure how big it can get. I plan on being the "team leader" because I have the most experience with C#/XNA and I'd like to learn how to be a team leader, this could be good training. So how should I proceed with this ? Whats the best way of leading a small team when you've never done it before ?


title: What is Pseudocode?

text: I've seen a lot of mentions of Pseudocode lately, on this site and others. But I don't get it:   * **What is Pseudocode?** For example, the Wikipedia article below says _"It uses the structural conventions of a programming language, but is intended for human reading rather than machine reading."_ Does this mean that it **_isn't_** actually used to make programs?   * **Why is it used?**   * **How is it used?**   * **Is it considered a Programming Language?** See the above Wikipedia quote.   * **Is it commonly known/used?**   * **Anything else...** I honestly don't know where to start with this. I have Googled it and I've seen the Wikipedia article on the topic, but I still don't fully understand what it is.


title: Object model design: collections on classes

text: Consider Train.Passengers, what type would you use for Passengers where passengers are not supposed to be added or removed by the consuming code? I'm using .NET Framework, so this discussion would suit .NET, but it could apply to a number of modern languages/frameworks. In the .NET Framework, the `List<Person>` is not supposed to be publicly exposed. There's `Collection<Person>` and `ICollection<Person>` and guidance, which I tend to agree with, is to return the closest concrete type down the inheritance tree, so that'd be `Collection<Person>` since it is already an `ICollection<Person>`. But Collection has read/write semantics and so possibly it should be a `ReadOnlyCollection<Person>`, but its arguably common sense not to alter the contents of a collection that you don't have intimate knowledge about so is it necessary? And it requires extra work internally and can be a pain with (de)serialization. At the extreme ends I could just return `Person[]` (since LINQ now provides much of the benefits that previously would have been afforded by a more specified collection) or even build a strongly-typed PersonCollection or ReadOnlyPersonCollection! What do you do?


title: I just started a job with Scrum and something seems to be missing. I am new to Scrum

text: The code is a complete mess of a combination of classic ASP/ASP.NET. The scrum consist of us patching up the big mess or making additions to it. We are all too busy doing that to start a rewrite so I am wondering.. Where is the part in Scrum where the developers can have the power to say that enough is enough and demand that they are given time to start the big rewrite? We seem in an endless loop of just patching old code with 'Stories'. So things are being run by the non-technical people who seem to have no desire to push for a rewrite because they don't understand how bad the codebase has gotten.. So who is in charge of making this big rewrite change happen? The developers? The Scrum Master? The current strategy is just to find time and do it ourselves without the higher-ups involved since they are mostly to blame for the current mess we are in.. `<-` insert rant about non-technical people telling technical people what to do here `->`.


title: How to pass around a debug flag variable?

text: I need to generate debug output in a java appliation that cannot be debugged by placing break points and traces. I've thus far been placing the debug flag as a static variable in one of the classes and then accessing it from all other classes. But this I suspect will eventually cause massive issues later on. What's the best way to do this?


title: Univeristy Projects and Uniqueness

text: I am in the process of trying to identify a suitable project for my final year at university. How important is it that the project be unique? I really want to do a project with the Kinect and am eagerly awaiting the official SDK. As yet I am struggling for an idea. However, I have looked at kinecthacks.com to see what other people have been working on, and a few of these ideas interest me. Would you think it is ethical to take one of these ideas and implement yourself? Obviously one would try to implement additional functionality on top of what is already there? Thanks.


title: Is it good to publish the software and development technologies?

text: I did some research on developers in my area. I was mainly interested in their products and the kind of tools they used in building them. I want to make this information public, but I was just wondering if it is a good idea. What I mean is, if the developer used Apache, MySQL and PHP and I made this public, does it make it easier for people to hack their product?


title: Different callbacks for error or error as first argument?

text: We (and the JS SO chat room) had a talk with @rlemon some days ago about his Little-XHR library about error handling. Basically, we wanted to decide which error handling pattern should be used:               xhr.get({         // Some parameters, and then         success: function(data) {},         failure: function(data) {}     })      Or:               xhr.get({         // Some parameters, and then         callback: function(err, data) {}     })      One is more jQuery-like, while the other is more Node-like. Some say that the first pattern makes you think more about handling error. I think the opposite, since you may forget the other callback function, while the argument is always there on the second pattern. Any opinion/advantage/drawback about both these patterns?


title: How do you change how intellij auto formats code?

text: IntelliJ does some odd formatting with Javascript code and I am trying to figure out how to get it to stop formatting this way. Whenever I chain jQuery functions together, it over indents the auto created code such as this:               $('#something').focus(function() {         /* Do some stuff */     }).blur(function() {             /* this is where the cursor and closing braces end up */             })      I want it to look like this:               $('#something').focus(function() {         /* Do some stuff */     }).blur(function() {         /* cursor and closing braces indented normally */     });      How do I change this?


title: How to implement session state in a backend web application?

text: When using a non-MVC service-oriented/Interactor pattern approach to decoupled system architecture, how is session state implemented? I've been thinking of building the frontend of an application using MVC (PHP/Ruby etc.), and send messages to a command-line backend which is the actual application. Since I want the offline application to be completely in control of functionality I would imagine using an offline session management system to work best, which at login issues an ID that is thereafter sent to the application on every request. The ID would be stored in a cookie on the client-side, just like a regular session cookie. Since the frontend works through HTTP requests anyway it makes little sense to do it any other way to me. Are there any better alternatives to this method that I should consider? I would prefer to keep the actual system completely decoupled from the web UI and also plan on implementing a desktop UI aswell, so the Interactor pattern seems to be the best way to achieve this to me. What I'm explicitly trying to avoid is the "do everything in our MVC framework! (and be stuck forever)" that seems to be popular nowadays.


title: Algorithm to optimize grouping

text: I would like to know if there's a known algorithm or best practice way to do the following: I have a collection with a subcollection, for example:               R1 R2 R3     -- -- --     M  M  M     N  N     L  L        A      What i need is an algorithm to get the following result:               R1, R2: M N L     R2: A     R3: M      This is -not- what i want, it has more repeating values for R than the above:               R1, R2, R3: M     R1, R2: N L     R2: A      I need to group in way that i get the most optimized groups of R. The least amount of groups of R the better so i get the largest sub collections. Another example (with the most obvious result):               R1 R2 R3     -- -- --     M  M  A     V  V  B     L  L  C      Should result in:               R1, R2: M V L     R3: A B C      I need to do this in LINQ/C#. Any solutions? Tips? Links?


title: Why can't we use unique identifier as combination of email and password?

text: For prevent email conflicts for authentication system we can surely choose email and password combination as unique identifier. What can prevent me to built authentication system by treating unique identifier as combination of email and password ? What is wrong with this design ?


title: What data structure could a word processor use to map the user's caret position/text selection to its internal representation of the document?

text: Word processors (e.g. Microsoft Word) display documents to the user as styled text. The user can select a part of this text and apply styles to it, and edit the text. The word processor must (I guess) have an internal representation of the document that indicates which bits of the text displayed to the user should be styled differently. But the user doesn't interact with this internal representation. They interact with the text, by using the caret and selecting portions of it. What data structure might the word processor use to efficiently map the text with which the user interacts to its internal model of the document?


title: Motivation and pitfalls (?) of the auto keyword in C++11

text: I was recently wondering why the keyword `auto` was chosen in C++11 to mark a variable whose type must be inferred by the compiler, like in               auto x = 1;      Since   1. `var` seems more common in other programming languages (e.g. C#, Scala, JavaScript), and   2. As far as I understand the new semantics of `auto` breaks backward compatibility (it was rarely used but had a different meaning in previous revisions of C++, see e.g. here) I wanted to ask if there was a special reason for choosing `auto` (in favour of `var` or any other keyword). Was there any specific discussion about this issue before the C++11 standard was released? Also, are there any possible incompatibilities we should watch out for when recompiling legacy C++ code with a C++11 compiler?


title: Using my own code in freelance projects

text: I have been into freelance business for more than 2 years. While doing projects for other people, I've build a compilation of common tasks that I implement in projects and put them into code. It's kind of a library with some functions that I can reuse without having to rewrite the same thing dozen times. I'm talking about accessing Access databases, downloading information from FTP and similar stuff. Is this acceptable from a legal point of view? What's the difference in reusing the old code and rewriting it from the scratch (using you own brain again, therefore the exact same logic)? I do not hold any copyright to it, of course, and provide the source code for these classes to my clients.


title: Windows Hibernate API

text: Is it possible to programmatically trigger the Windows's Hibernate without actually Hibernating, just to take snapshot of the OS at regular intervals? So that the system can return to the previously saved state in case of any failure. This is much like System Restore, which backups system files; but the idea is to backup the complete OS's active state.


title: Pushing for greater automated testing on a QA team

text: I'm a junior developer joining a QA team at my company. The QA team I had been interacting with while working as a developer was very solid and the business had been very good about encouraging and funding good, solid automated testing techniques and hiring people who were good at it. However, this new team I am joining looks like it might be a little more reactive in nature, blending some of the testing responsibilities (as I understand them) with ops work and not doing a lot of proactive regression testing. I'm hoping dearly that I am wrong, but the fact is I could be right as well. Does anyone have any good advice for promoting automated testing? Bear in mind that I'm not a manager or lead, and also not even an experienced tester. But on some level, it feels like some of these principles should fall into common sense. Am I wrong for thinking that? If not, what should I do?


title: Getting overwhelmed after starting a new project

text: I started a project (a Windows based timetable program that helps you stay organised with your subjects and assignments). The problem is that I'm not sure how I should manage this project and what order to build things. I.e. Should I build all the different interface elements then write the code or should I make an interface, code it, make another interface then code that? So my question is; how do I split up this longish project into small, ordered pieces to complete; and how should I order this?


title: Designing an API on top with Java RMI and Rest APIs

text: I'm working on the backend of a java web application. We have a document repository (Fedora Commons specifically) where we house xml files. I want to abstract the API of the repository internally so that we aren't tightly coupled to one product. I'd also like to give the flexibility of connecting to to a repository via Java RMI or REST APIs. I was hoping to get advice or resources on how to implement something like this. My thought it that I'd have some abstract repository class that had methods like getRecord, updateRecord, and deleteRecord. In the constructor I would pass the URI for the repository and the API method and port. This would allow some flexibility in the future so that if the REST api became more practical, but allow the flexibility or using RMI which could (should?) have better performance. Am I over thinking this or am I on the right path?


title: Mixing Angular and ASP.NET MVC/Web api?

text: I come from using ASP.NET MVC/Web API and now I am starting to use Angular but I am not clear on the proper way to mix them. Once I am using Angular does the MVC sever side concepts still provide any value ? Or should I strictly be using Web API purely to get data for the angular HTTP calls ? Is there maybe a more stripped down starting point I should use if the VS template is adding a lot of stuff I don't need ? I like the idea of a strict divide of server side = pure data and client side = pure HTML processing Any tips you have for a ASP.NET MVC guy transitioning to Angular would be helpful


title: Working with Multiple XML Schema Classes in C#

text: I'm working with a data import process in C#, which takes a zip file filled with XML files and saves specific data points into a database. This is accomplished by loading the XML data into classes compiled from the schema. The import logic retrieves the data by digging down into the right classes and fields. The XML schema is defined by a different company, and the schema changes every one to years when an updated version of their software is released. What my company would like to do is be able to import different versions of the schema so that we could support older files. There is also debate on whether this change is worth the effort. My plan to accomplish this would be to determine which schema to use at the beginning of an import, and then use different interfacing classes to get the data from the XML and pass it back to the import classes, which would then save the values to the database. There are over 200 classes generated based on the schema, but we only need to access data in about half of them. Are there other ways to approach supporting multiple XML schemas that may be easier?


title: Standard/Proper way of counting lines of code?

text: How should I count the lines of code in a project? In C++ for example, should I count the lines of the header files with my class definition? Should I count the header of a (non standard) library I am linking against? In Qt (or any other GUI framework), should I count the lines of the form's design? Should I count the Makefile too? I ask because it is a simple way to measure the size of the project and/or effort involved. Even though a GUI file is not code _per se_ the programmer might have spent hours doing it. **EDIT** Most of you did not understand the question and/or are assuming that I want to use the magical number of LOC as the ONE AND ONLY metric to rate a project or even a day of work. I consider a negative LOC day a very nice day. It means I've somehow managed to understand and model the problem better and more efficiently. Comments like "Why do you need this" are not interesting. Like it or not, the number is out there, Wikipedia says Windows XP is rated at 45M LOC, Linux 2.6.35 at 13.5M, I could go on. Maybe I could have asked better. Anyway, my original intent was to know how those numbers in Wikipedia were calculated and not the subjective nature of them. I found this in a MSDN blog, very useful as it shows how VS2008 does it: ![enter image description here](http://i.stack.imgur.com/KKXGQ.png)


title: Build times for small incremental changes to C# Web Applications

text: I have recently been moving away from ASP.NET Websites in favor of Web Applications. More specifically I have recently been picking up MVC as an alternative to developing ASP.NET Forms websites. Something that I find highly frustrating is the constant build->change->re- build process when testing small changes to compiled code. I find myself 'bundling' several changes between builds just to avoid waiting 20-25 seconds for Visual Studio to crunch it's way through the compilation process. I created a clean MVC 4 project from the VS template and timed the build after making a single line code change, it took 19 seconds. When making a change in the code-behind in an ASP.NET website I've always found that the page is seemingly re-compiled on the fly when you next hit the page. This would seem to me to be a better environment for web development rather than VS forcing an entire rebuild after every small code change. In the past I have enjoyed the luxury of making a change, hitting refresh in the browser, and waiting 1-2 seconds for my result. Is this achievable with web applications built using Visual Studio?


title: HTTP PHP Authentication and Android

text: I am working on a website for which I hope to have an application for as well. Because of this, I am creating PHP API's which will go into my Database and serve specific data based on the method/function called. I want to protect these API's from misuse however, and I plan on implementing Authentication Digest to do so. However one of the OS's I want to support is Android. And I know that a malicious user would be able to reverse engineer the Android app and figure out my authentication scheme. I am left wondering:   1. Is there a better way to protect these API's from misuse?   2. Is there a way to prevent a malicious user from reverse engineering the app and potentially seeing the source code for it, enabling them to see my authentication scheme?   3. If none of these are preventable, then is my only option to have a Username/Password cred specifically for the Android app, and when eventually hacked, change the creds and issue an update for the app?


title: Diving into microcontroller programming

text: I just got a batch of LED matrix modules from Sure Electronics (http://www.sureelectronics.net/goods.php?id=1120) and a driver board (http://www.sureelectronics.net/goods.php?id=972). I've got it wired up, and connected to my Mac. I found the right drivers, and I'm now able to send text to the displays using the virtual COM port, as per the documentation from Sure Electronic's website:               start with "0xFE,0x47 (G) 0x01,0x01" followed by 16 characters - display the 16 characters in the first row     start with "0xFE,0x47 (G) 0x01,0x02" followed by 16 characters - display the 16 characters in the second row      The plan is to hook it all up to a Raspberry Pi (when I eventually get one) and use it all to display information from a web service. However, this setup is not optimal. The driver board requires some initialization each time it is powered up, in order to be available via USB. Also, I'd like more control over the display of characters (this setup, for instance, does not support non-ASCII characters, or text scrolling). Heavy googling has led me to believe that I need to go deeper into the HT1632 chip on the driver board. The documentation from Sure Electronics is sparse. The goal would be to be able to address each LED pixel individually from my code running on my computer (as in a 2D array of booleans, for example). I'm totally new to micro programming, so I have no idea where to start. What do I need to do in order to program it? Can I even modify the code of the driver board, or do I need another kind of driver board? And how do I automate the boot up sequence, so that the board is automatically USB enabled? Also, I'm mostly a Java/Web developer guy, so I would like to avoid as much C programming as possible. If anyone with experience with this kind of programming could point me in the right direction to start, I would be grateful.


title: Does the lack of states on HTTP make the protocol unfit for modern applications?

text: I changed from PHP to ASP.NET, now I’m working with webforms in a somewhat large company. I given some though and research to back my impressions on ASP.NET webforms and I came to the conclusion that Webforms is an attempt to make web applications easier to write for those who came from the "desktop programming" world. But before shunning WebForms I decided to analyze the needs of the software we write and bumped on the issue of maintaining application states on the Web. I understand that HTTP is a stateless protocol, and ASP.NET tries to simulate states with session variables , hiddenfields and viewstates, it is in my understanding also that all of the above cited have flaws and are not perfect ways to keep the state in my application, But I also understand the need to keep a state on my app. Which raises the questions, is the HTTP really fit for this type of job (making applications that require state)? Are the tools currently available to webdevelopers enough? Are the new tools available with HTML5 effective at the job or are they just workarounds for the limitations to HTTP. I love developing for the web, and I’m much more familiar with the web than with the desktop, I just been wondering about this HTTP statelessness thing for some time and i want to understand if I’m missing some point or if I’m right on my notions.


title: is it possible for the author to trademark the name of an open-source application?

text: I would like to know if the name of an open-source application can be trademarked by the original author and what it means when it comes to distributing it through major linux distros, that is, will they accept this kind of software?


title: How to efficiently store IP addresses?

text: **Background**   I have a requirement where I need to remove a few nodes in a network based upon a command given by the user. To keep the nodes from transmitting or receiving data I thought of changing its IP address to some other address. Before I change the address I want to save the node's IP so that I can re- assign the original IP back to the node after the simulated network outage is over. My problem is how to efficiently save the nodes' IP addresses. Should I use a linked list or a hash table?


title: What programs emit C++ code and pass it to mainstream compilers?

text: I suspect there're programs that instead of emitting machine code instead emit C++ code and then start a mainstream C++ compiler to compile it to machine code. I can't find any notable examples except MIDL which emits some rather primitive code. What are notable examples of such systems?


title: Storing Dynamic SQL in text files vs inline code

text: Our Architecture team is proposing a framework that would see our SQL queries moved from coded strings within our applications, into a file based system where we would invoke them with function calls. Our application makes heavy use of SQL queries ranging from the mundane, to very complex. This is a .NET solution. The idea is that each query would be written to text files, and we would be able to tag fields, joins, and conditions with attributes. When calling our SQL functions, we could pass arguments to toggle these attributes on/off based on our business logic, allowing for only the portions of the SQL we need to be executed. Although I like the idea of abstracting away our SQL, I am skeptical that this system will result in any tangible benefits. The major driver of this is our past experience where many coders created some massively bungled dynamic SQL functions which were impossible to understand. The idea is that this will make it easier to define your queries, will make all queries more easily testable, and clearly define the business logic involved. I am unsure if this will survive the test of reality. I’d like to get some feedback on the pros/cons of this approach. Also, before anyone suggests it, the Entity Framework was rejected due to questionable support from our database provider (Teradata).


title: Calculating local results from global values using SQL and PHP

text: I have an interesting problem for you all. I have a partial solution but I feel you guys can come up with an efficient solution. What I have a SQL table with following structure: StockId <\- a unique ID for the share StockHolderId <\- a unique ID for the share holder StockPrice <\- The price of the stock - if this is a request to purchase this is kept -1 BuyingorSelling <\- value of 1 means the holder wants to buy, value 2 means he is selling StockQuality <\- a special record that stores a value calculated based on some complex computation. The values are 1, 2, or 3 based on let us say bad, neutral, good. What I want to do is to find out who all can give me the stock I want to buy and who can purchase the ones I got. I want the person who gives a good quality stock (local value) at cheapest price (global value) to be my best selling match and the person who can buy most (semi global) of my stocks to be my best buying match. The formula to rank the seller is 0.5 * price + 0.3 * availability + 0.2 * quality. How would you go about it? Any ideas? I have created a table that joins with itself to get info of every match and then grouping but how can I acquire the price value to be cheapest?


title: Objective-C Categories and Sprawling Classes

text: The generally accepted programming practices I've come across tend to advise against big, sprawling classes. Does using Objective-C categories change the conventional wisdom somehow? Is it more acceptable to have bigger classes if each "subclass" or set of tasks is in its own category? In my own experience, I've found that where I might've in the past tried to split classes, I now sometimes find it easier and rather maintainable to just split categories, but am I setting myself up for future maintenance hell (or other kinds of hell) by doing this?


title: Licence all code?

text: Should every piece of code put online have a licence with it, or should it explicitly mentioned that it is in the public domain? I'm writing a simple python script that will take a project euler problem number and save a file with the question text as comment. As I was creating the directory and initializing git I added a licence file, which got me thinking is it even necessary to put a licence for something so simple. So, should every project no matter how trivial have it's licence explicitly mentioned or is it just overkill to put a licence with such small scripts? What is the recommended practice here?


title: Data Structures usage and motivational aspects

text: For long student life I was always wondering why there are so many of them yet there seems to be lack of usage at all in many of them. The opinion didn't really change when I got a job. We have brilliant books on what they are and their complexities, but I never encounter resources which would actually give a good hint of practical usage. I perfectly understand that I have to look at problem , analyse required operations, look for data structure that does them efficiently. However in practice I never do that, not because of human laziness syndrome, but because when it comes to work I acknowledge time priority over self-development. Over time I thought that when I would be better developer I will automatically use more of them - that didn't happen at all or maybe I just didn't. Then I found that the colleagues usually in the same plate as me - knowing more or less some three of data structures and being totally happy about it and refusing to discuss this matter further with me, coming back to conversations about 'cool new languages' 'libraries that do jobs for you' and the joy to work under scrumban etc. I am stuck with ArrayLists, Arrays and SortedMap , which no matter what I do always suffice or either I tweak them to be capable of fulfilling my task. Yes, it might be inefficient but do we really have to care if Intel increases performance over years no matter if we improve our skills? Does new Xeon or IBM machines really care what we use? What if I like build things, but I am not particularly excited whether it is n log(n) or just n? Over twenty years the processing power increased enormously, which gives us freedom of not being critical about which one to use? On top of that new more optimized languages appear which support multiple cores more efficiently. To be more specific: I would like to find motivational material on complex real areas/cases of possible effective usages of data structures. I would be really grateful if you would provide relevant resources. There is similar question ,but in the end the links again mostly describe or do dumb example(vehicles, students or holy grail quest - yes, very relevant) them and people keep referring to the "scenario decides the data structure to use". I want to know these complex scenarios to be able to identify similarities to my scenario and then use them. The complex scenarios where it really matters and not necessarily of quantitive nature. It seems that data structures only concern is efficiency and nothing else? There seems to be no particular convenience for developer in use one over another. (only when I found scientific resources on why exactly simple carbohydrates are evil I stopped eating sugar and candies completely replacing it with less harmful fruits - I hope you can see the analogy)


title: Implementing the command pattern in a RESTful API

text: I'm in the process of designing an HTTP API, hopefully making it as RESTful as possible. There are some actions which functionality spreads over a few resources, and sometime needs to be undone. I thought to myself, this sounds like a command pattern, but how can I model it into a resource? I will introduce a new resource named XXAction, like DepositAction, which will be created through something like this               POST /card/{card-id}/account/{account-id}/Deposit     AmountToDeposit=100, different parameters...      this will actually create a new DepositAction and activate it's Do/Execute method. In this case, returning a 201 Created HTTP status means the action has been executed successfully. Later if a client wishes to look at the action details he can               GET /action/{action-id}      Update/PUT should be blocked I guess, because it is not relevant here. And in order to Undo the action, I thought of using               DELETE /action/{action-id}      which will actually call the Undo method of the relevant object, and change it's status. Let's say I'm happy with only one Do-Undo, I don't need to Redo. **Is this approach ok?** **Are there any pitfalls, reasons not to use it?** **Is this understood from the POV of the clients?**


title: How to speak to a computer

text: I am a self-taught, novice programmer. The language I chose was Objective-C, so that I can write Apple applications and software. I have learned the hard way that Objective-C has a steep learning curve, but I have forced myself to look at it over and over until I get it right. I feel I am completing one major step, and that is becoming very comfortable with the syntax. Now as I enter the next big step - finding out what is possible with a computer programming language - I am thinking that all software is just developed within the confines of:   * classes   * loops   * booleans   * IF/OR statements   * variables   * etc.  Is that a true assessment? When thinking of software in my head do I just need to learn to convert it all to the above? Right? Sorry if this question sounds funny, but I am just learning how to take the language in and talk (what I think is) the language of a computer. Is there a good book or tutorial that helps illustrate how to "speak as a computer would"?


title: Should I Do Calculations in T-SQL or Program?

text: I am creating a stored procedure that is logging some data. The data ultimately needs to end up in 2 tables. The incoming data is coming from a JSON string containing 15 parameters, and the data is then logged to the database using the stored procedure I'm writing. I would like to send the data into 1 stored procedure and INSERT it into both tables. The first table is a raw data logging table. It will be used for debug and troubleshooting. The second table will be used for report generation. This table requires some simple mathematical calculations to be done on incoming data. For example: `DECLARE @Table2Fld3 DECIMAL = @IncomingFld9 - @IncomingFld4;` I'll have about 8 of these calculations to do to compute the values for table 2, then I'll do an INSERT to save the data. So my question is, is it a good practice to do these calculations in the T-SQL? Or would it be better for me to create 2 separate stored procedures and do the calculations in my code? One trade-off I see is that if I do it all in the code then I have to create 2 database connections. **EDIT** I should elaborate on the "2 database connections" comment. The application in question is a windows service that establishes multi-threaded server/client communication. The logging system is asynchronous to the server/client communication. Using that existing system, in order for me to target multiple stored procedures, it would require 2 calls to the logger which would spin up 2 connections to the database.


title: Why are inheritance and interfaces restricted to instance members?

text: Disclaimer: I think the rules are almost the same in most OO languages, but since I'm most familiar with C# I'll be relating to this specific language. I think that the use of attributes and reflection could be largely reduced if static members would apply the same principles as OO instances. Static properties and methods can be "overridden" by decedents by using the new keyword, but they cannot be forced to implement one via an interface, neither can the 'base' keyword be used (only explicitly naming the base type is supported). To make things worse, the members cannot be referenced via an instance, but have to always be specifically qualified with the exact type. Constructors also have limited "inheritance" support, one can choose which base constructor is called, but you cannot force an object to support a constructor that takes certain parameters by defining it in an interface. The best hint I could find to answer this question so far is this one on stack overflow (answering a different question). In his answer Jörg points out three principals that apply to Object Orientation:   * messaging,   * local retention and protection and hiding of state-process, and   * extreme late-binding of all things. Now I fully understand that if you want to pass on a state-full class from one method to another as an object, these principles make sense. However in my opinion the principle of inheritance, overriding base methods with alternative or additional functionality, could also be beneficial to stateless business logic. One example where forcing an object to implement a certain constructor would be helpful is with de-serialization. For example where the constructor should accept an XML node. In C# it is dynamically implementable using reflection, but having compile-time errors and avoiding the reflection boilerplate would add lots of value! Static method/member interfaces would be helpful in situations where some aspects of a value are type specific, without any relation to the instance. For example a class could have a DisplayName, Unit, Weight, Factor or other aspects that are the same across all instances of the specific type, regardless of the instance value. Attributes (or Annotation) can be used to exploit these without the need to create an instance, however, there again it's extra boilerplate code and no way to enforce their implementation with compile-time errors. I admit there are many simple ways to work around these points, I'm not looking for workarounds. Returning a static value in an instance-property is quite common, and it is not that much overhead to create an instance of an object just to read out the type-specific aspects, but I'd like to know the rationale background on why static things have been systematically excluded. I have heard about "the virtual stack" before, but don't really know how it works technically (and cannot find any simple explanation on the net). Are the reasons of technical or philosophical nature? * * * Edit: elaborating on static interfaces: An example of how I think a static interface could provide a strongly typed, compiletime checked, alternative to reflection:               public staticInterface MyStaticInterface     {         constructor(XmlNode node);         string DisplayName { get; }         int Weight { get; }     }      The usage:               public void FillNodesToolBox()      {         MyStaticInterface[] nodes =              assembly.GetTypes().Where(t => t.Implements<MyStaticInterface>());              for (int i = nodes.Length - 1; i >= 0 ; i--)         {             Console.WriteLine(string.Concat(                 nodes[i].DisplayName, " (", nodes[i].Weight.ToString(), ")"));         }     }      Looking back, this actually looks like making my Type object inherit from System.Type, adding some properties to it, which is different than a static member... `string.Empty != typeof(string).Emty` (the latter will not compile). Maybe I'm starting to find the answer, but it feels like I'm walking in a paradoxical circle, it doesn't quite 'snap' yet....


title: Teaching `class`es and objects in C++ to university students

text: To learn `class`es and objects at my university, students are required to develop a simple game (nine-mens morris or something similar) using Java. Java is used because of its libraries and tool support. What is the counterpart for C++. * * * _Background_ : I am a researcher at a university working with drones. The programming language for the research group is naturally C++. However, like most universities the introductory language of choice where I work is Java. The problem is when the students join the research group, it is hard work to "unlearn" Java for C++. IMHO, it hurts more than it helps. I want to propose teaching C++ instead; but I need to offer an alternative for learning `class`es and objects.


title: Simple, permanent queue system with pub/sub for Node.js?

text: > Highly related Nodejs: many clients requests through one socket I'm investigating a robust message passing system for this application of mine. The easyest solution would be Redis pub/sub (it's simple, effective and I'd also use Redis for caching) but as I understand it, publishing is a "one shot" operation only to actually subscribed clients. Whoever subscribes after the publishing, does not get the message. I'd like to be able to "stash" unreceived messages for a while, so if I reconnect to the channel I'd get back the messages I've not received. I know that systems like ActiveMQ with the ack and permament queue mechanism would solve this issue easily, but I'm wondering if there could be a simpler solution/approach. What do you think?


title: Webservice Return Generic Result Type or Purposed Result Type

text: I'm building a webservice which returns JSON / XML / SOAP at the moment.. and I'm not entirely sure which approach for returning results is best. The Client Consuming the Services will generally be Web Applications / Mobile Web Applications. But could be from various WordPress and other social media Plugin type systems. Which would be a better return value? A generic "transfer" type structure, which carries Generic properties or a purposed type with distinct properties:               class GenericTransferObject{         public string returnVal;         public string returnType;     }      VS               class PurposedTransferObject_1{       public string Property1;     }          //and then building additional "types" for additional values     class PurposedTransferObject_2 {       public string PropertyA;       public string PropertyB;     }      Now, this would be the serialized and returned from a web service call via some client technology, JQuery in this example. SO if I called: /GetDaysInWeek/ I would either get back: {"returnType": "DaysInWeek", "returnVal": "365" } OR {"DaysInWeek": "365"} And then it would go from there. On the one hand there's flexibilty with the 1st example. I can add "returnTypes" without needing to adjust the client other than referencing an additional "index".. but if I had to add a property, now i'm changing a structure definition.. Is there an obvious choice in this situation?


title: Code formatting SQL queries

text: Should I break SQL queries in different lines? For example in the project I am working on, we have a query that is taking 1600 columns! 1600 + tab chars. I wrote queries like this:                  "SELECT bla , bla2 , bla FROM bla " .           "WHERE bla=333 AND bla=2" .            "ORDER BY nfdfsd ...";      But they demanded me to put them in one line and said that my style is bad formatting. Why it is bad practice?