title: How should I implement "queueing" of approval on my objects?

text: I have a list of objects that will need to go through an approval process. I am curious if it would be best to simply add some properties to my object, like `ApprovedBy`, and `ApprovedOn`. Another option is to create an `ObjectApproval` class that contains this information as well as other information that needs to be stored. If I wanted a list of objects that still needed approval, I could simply query for a null `ApprovedBy` in the first scenario. In the second scenario, I would have to maintain an accurate list of `ObjectApproval` items. The next thing is, what if I need a multi-step approval process? In this case, I think it would be better to create an `ObjectApproval` type to track all the intricate details, and I could simply query for the `ObjectApproval.Step` (or something similar) to find out the items a specific user needs to approve based on their role Any thoughts on this? Or perhaps design patterns to recommend?


title: What is the best solution for static memory allocation?

text: I'm working on image processing and I need to use big Images in a critical system. A good practice for critical systems is to avoid dynamic allocation of memory but what is the design/recommendations for static memory allocation? If we do a static allocation of a big matrix we get stack overflow.               class test     {         public:             test(){};             ~test(){};              private:             float m_bigMatrix[3000000];     };      To solve this problem we can define the matrix as static, but then this matrix will be the same for all the instance of this class.               static float m_bigMatrix[3000000];      The other solution is to have a static object.               static test t;      I've got a solution from another forum where it was suggested that the best approach would be to use a class specific for memory management. All the instances of the class are static and are used by other classes throughout the code. Here is a sloppy version for this solution (it's just an example):               class MemManager     {     public:         MemManager(){ m_counter = 0u; }         ~MemManager(){ printf("Out of MemManager nbr %d\n", m_counter); }              uint16_t getCounter() { return m_counter; }         uint16_t getData(uint32_t pos) { return m_data[pos]; }              void setCounter(uint16_t val) { m_counter = val; }         void setData(uint16_t val, uint32_t pos) { m_data[pos] = val; }          private:         static const uint32_t MEM_SIZE_DATA = 100000000u;         uint16_t m_counter;         uint16_t m_data[MEM_SIZE_DATA];          protected:     };          class MemUser     {     public:         MemUser(){ m_memManager = NULL; }         ~MemUser(){ printf("Out of MemUser\n"); }              void init(MemManager& memManager) { m_memManager = &memManager; };         uint16_t getCounter() { return m_memManager->getCounter(); }         uint16_t getData(uint32_t pos) { return m_memManager->getData(pos); }              void setCounter(uint16_t val) { m_memManager->setCounter(val); }         void setData(uint16_t val, uint32_t pos) { m_memManager->setData(val, pos); }          private:         MemManager *m_memManager;          protected:     };          int main()     {         static MemManager mManager;         mManager.setCounter(1);         {             MemUser mUser;             mUser.init(mManager);             printf("Exit scope\n");         }         for(uint8_t i = 1u; i<5u; i++)         {             static MemManager mManager2;             printf("Note that mManager2 is the same: %d\n", mManager2.getCounter());             mManager2.setCounter(i);         }         printf("Exit process\n");         return 0;     }      So, is this correct? What is the best solution?


title: When will java change to 64bit addressing and how can we get there faster?

text: Having to work with large files now, I would like to know when the java libraries will start switching to long for indexing in their methods. From Inputstreams read(byte[] b, int off, int len) - funnily there is long skip(long) also - to MappedByteBuffer to the basic indexing of arrays and lists, everything is adressed as int. Is there an official plan for enhancment of the libraries? Do initiatives exist to pressure oracle into enhancing the libraries, if there is no official plan yet?


title: Learn a language bottom-up or top-down?

text: When starting the first project in a new language, you have basically two approaches to learning. Either you do a quick Google search, pull together the most popular frameworks and libraries and work your way from their tutorials towards what you want to achieve (top-down). Or you start with the language basics and the standard library and by and by replace your own simple components with more sophisticated third-party components once you know what you're searching for (bottom-up). Now I'm about to embark on my first serious Javascript project. There's probably as much to know about the language as there is about jQuery, ExtJS and whathaveyou, and I'm trying to decide what to focus on.


title: Licensing for a web based desktop application?

text: I have created a desktop application(winfoms) using C#.net 3.5, the application is an SEO application, so it has to be connected to the internet, i implemented a simple licensing routine where every time the application is started it will query the web service on my server with the key and machine hash to validate. But recently i have noticed that some "crackers" have disabled the license verification (simply removed the lines of code that does that) of the application which i have obfuscated, and the sad thing is that they are selling it at a cost that is only 10% of what i am selling for, they didn't even bother to remove my website address and company details from the about box. The application is having an auto-update feature, which they so-called crackers have intentionally left it on in the cracked version I was just trying to figure out a way out of this, i can release an update and disable all the versions that are brought from the crackers, but without a proper licensing it will broken again and the next time, i don't have the guarantee that they will keep the auto update feature on.


title: How many are too many interfaces on a class?

text: I would probably consider it a code smell or even an anti-pattern to have a class that implements 23 interfaces. If it is indeed an anti-pattern, what would you call it? Or is it simply just not following the Single responsibility principle?


title: Can I change operator precedence and associativity in C++?

text: As the title says, I find it useful to be able to overload operators. Is it possible to also change the way the operators are parsed by specifying the precedence and associativity of overridden operators?


title: When to use event.initMouseEvent for simulating mouse clicks?

text: I wonder if there are benign use-cases for simulating mouse clicks using event.initMouseEvent. I found that it is used for creating pop-under ads in the following way:                       var e = document.createEvent('MouseEvents');             e.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, true, false, false, true, 0, null);             a.dispatchEvent(e);      This code simulates a click on the opening browser window, to force the newly opened window beneath it. Evil. I'm thinking of simply preventing all simulated clicks in my own browser via a browser extension, but I wonder if I might break useful websites and behavior in the process. Therefore I wonder what situations justify simulating mouse clicks, and if there are big sites that use it in non-evil ways.


title: Algorithm to analyse and predict

text: I'm having a set of data's, say               Question,     Question's Main Category,Main Category followers,     Question's Related Categories,Each Related Categories followers,     Whether it got answer in 24hrs [Yes/No]       Now, I need to analyse a database with thousands of sets of data's like given above and predict whether the new given question(with all details like main category,followers...etc) will get answer in 24hrs or not ? I have no idea which algorithm will be more suitable to solve this kind of problem.


title: How to develop an attitude for abstraction fundamentals?

text: I know it's mostly a psychological question, but what practices exist for a software developer to improve the _sense_ of **recognizing basic concepts** in the domain and the _habit_ to **define simple reusable expressions** for them instead of duplicating their definitions all over the code? I'm not speaking about hard-to-learn tools for abstraction but trivial, essential ones like constants and functions that every programming language has. For example, if someone has the task of changing multiple string literals in the code by adding a prefix to them, instead of `"FooBar"`, they should write (pseudocode):               def prefix = "Foo"     prefix + "Bar"      Or if there is a domain-specific derived property of a certain type of entity to compute, introduce a function for that which clearly reflects the nature this derived property:               def boolean isRight(Foo foo) = foo.bar.length > 0      The problem is that even more experienced developers sometimes fail to do this due to lots of possible causes (encountering a new programming language, time pressure etc.). Do you know any good, respectful ways to communicate this with fellow colleagues (not students) in order to let this approach become more instinctive?


title: Overloading Operators - C++

text: I was experimenting with new overloaded operators, I have created one void operator and another one that returns something when it's called:               #include <iostream>          struct chichachicha{         int operator()(){             return 25;         };     };          struct boomboom{         void operator()() {             std::cout << "Hi folks!" << std::endl;         };     };          int main(){         chichachicha objC;         int f = objC();         std::cout << f << std::endl;         boomboom objB;         objB();         return(0);     }      Is this the best way to write a code that does that? How can I write an operator that can be called from anywhere in the code without instantiating the associated struct, that returns `void`/nothing and only prints a string of text? I'm not considering static methods, just operators.


title: I'm a manager. How can I improve work relationships and communication with programmers?

text: A little background first. I'm a project manager at medium-sized company. I started as a CS major and had a little exposure to programming, but after a few months I knew it's not my path, so I switched over to management. That proved to be a good decision, and after graduating I've worked in software management at various companies (for 5 years now). Recently, we had a very painful project. It was the worst of the worst, with many mistakes both on our side and on the customers side and just barely ending it without losses. It has led to many frustrating situations, one of which escalated to the point where one of our senior developers left company after a vocal argument with us (the management). This was a red flag for me: I did something terribly wrong. _(for the record, the argument was about several mistaken time estimates)_ I searched many places for answers and a friend pointed me to this site. There are many questions here about frustrations with management. I can understand that the general bad experiences lead to a general reluctance against "those guys in the suits". I'm that guy in the suit. It may not look like it, but all I want is a successful project, and with limited resources it takes painful decisions. That's my job. One of the things the aforementioned senior developer complained about was work equipment. Frankly, I had no idea that the computers we had were not suited for working. After this, I asked many programmers and the general consensus was that we need better machines. I fixed that since then, but there was obviously a huge communication gap between me and the programmers. Some of the most brilliant developers are the most shy and silent people. I know that, and it was never a problem during an interview. People are different, and have strengths at different areas. The case of the underpowered PCs is just one of the many that led me to thinking that there is a communication issue. How can I improve communication with programmers without being intimidating and repetitive? What I'm hoping is that people don't complain about good things. If you love your workplace and love (or at least _like_ :)) your manager, please tell me about them. What are they doing right? Similarly, if you hate it, please describe in detail why. I'm looking for answers about improving communication because I think that is my problem, but I might be wrong.


title: Implementing Digitally signed data in a Web Application

text: I understand PKI well from a conceptual point of view - i.e. private keys/public keys - the math behind them, use of hash & encryption to sign a certificate, Digital Signing of Transactions or Documents etc. I have also worked on projects where openssl C libraries were used with certs for securing communication and authentication. I am also extremely familiar with openssl command line tools. However, I have very little experience with webbased PKI projects & hence I am trying to design and code a personal project for this. ## The requirements (This is a learning project - This is never going to be used in a bank) This is the website for a bank. All Internet Banking users are allowed use any signing certificate issued by a few known CAs (verisign, Thawte, entrust etc). The Bank is not responsible for procuring certificates for the user. The user logs into the bank site with his userid/password etc. He has access to most parts of his account. However, when the user wants to do a transaction - like transferring money to different account - the bank wants him to sign the transaction with a certificate. ## The design When user choses "Transfer" option - the website throws up a form where there are 3 entries - "Transfer To" account, the Amount of the transaction and a way for chosing a cert for doing the digital signing & do the signing. I concatenate the "Transfer To" Account no & the amount plus a nonce and this is the string which will be signed and sent to the backend. I have searched a lot but haven't been able to figure out how to achieve - letting the user chose a cert - do the signing. I know how the user can add certs to his personal truststore on Windows. But how would I ask the browser to show him certs to chose from? How does the signing get done - I really don't want to write crypto code in Javascript!!! So is the alternative having an ActiveX or a Java Applet? Is there a better way? Is there a way to ask the browser to use the cert and do the signing? I have not decided on a platform/framework/language for now - so this question is rather generic. I have searched a lot for this kind of info without luck - all I get is tutorials on digital signing, tutorials on how to enable PKI in Apache etc. If someone feels my whole approach is wrong & there is a better way to do digital signing in a web-app - feel free to suggest those alternatives also.


title: GUI-Development with QT for OpenGL/C++/MAC

text: I am a complete newbie considering QT. Would you say it is recommendable to use. I would like to build a GUI for my programm. I need about 10 buttons.(Maybe more) It would also be nice to have a regulator to choose colour like in photoshop. Is it hard to understand if you already have intermediate level in c++ and opengl. Which books would you recommend? Are there many differences between windows and mac, because it seems that there are much more books for windows. What else can you do with QT except for GUI- Development. Thanks in advance...


title: Watching file changes/additions/removal, but with an eye on partial transfer

text: I would like to monitor the filesystem in python, so that my application gets warned of the new file addition, file removal, or file change. Once the file is detected, the application starts extracting the contained data through various plugins. The problem is that I am dealing with big files, and when the user starts copying a file from outside into the watched directory, it will be detected, but it will appear as corrupted. Checking for file size between invocations is potentially a good strategy, but it ignores the fact that other generators of the file (such as wget) might have long pauses when the file is not changing in size, and yet is not completed. I don't have control of the file format I am downloading either, so I can't check for an end-of-file mark, because it could not be there. Is there a cross platform way (or different, platform specific ways for linux and windows) to solve this problem? Can I check if a file is currently open somehow? How is this problem solved in other software?


title: How is switch/case handled as to avoid comparisons to the case values?

text: I've read in multiple answers that switch/case avoids "unnecessary" comparisons, but I never learned this in college, and I'm a little stumped on how the program would figure out which case to jump to without doing a comparison. Obviously, in the case of `int switchVar=3; switch (switchVar) { case 0: ... case 1: ... case 2: ... case 3: ... case n: ... }`, this would be pretty easy, as it could just create an array of pointers that point to the beginning of each case's code block, and it would simply do something along the lines of `instructionPointer = switchJumpTable[switchVar];`. However, this breaks down if you were to do a switch/case on a string, e.g. `char switchVar[]="North"; instructionPointer = jumpTable[switchVar];` where trying to access the "North" index of an array would cause an error (or if the compiler allowed this behind the scenes, I still don't see how it would avoid comparisons when converting the char array into an integer in order to access the array.) I can think of one way to get around unnecessary comparisons, but it wouldn't be terribly efficient, so I'm sorta curious as to how this is actually done, as I can't imagine that compilers are using the method that I have in mind.


title: Should we quit trying to do agile if QA takes 12 weeks?

text: Someone in my company recently proposed changes to our core product that our managers feel should trigger what I guess my company considers a full QA cycle (i.e. testing the entire product suite from the ground up). Apparently our QA takes 12 weeks to do a full QA cycle for our product. My problem with this is that we are trying to do Agile (although mostly half-assed in my opinion) development. We will do a whole set of sprints and then do a release, which QA will take forever to go through I guess. The question is really, if our QA is going to take 12 weeks to do their job, shouldn't we just give up trying to do Agile? What the hell is the point of trying to do Agile in a situation like this?


title: What is the *correct* term for a program that makes use of multiple hardware processor cores?

text: I want to say that my program is capable of splitting some work across multiple CPU cores on a single system. What is the simple term for this? It's not multi-threaded, because that doesn't automatically imply that the threads run in parallel. It's not multi-process, because multiprocessing seems to be a property of a computer system, not a program. "capable of parallel operation" seems too wordy, and with all the confusion of terminology, I'm not even sure if it's accurate. So is there a simple term for this? Edit: The parallelization framework used by my program implements parallelism by forking multiple processes and communicating between them. Edit 2: I found the following in Wikipedia's article on Concurrency: "Concurrent programming is usually considered to be more general than parallel programming ..." Based on this, both "concurrent" and "parallel" are apt descriptions of my program, with "parallel" being the more precise one. However, I realize that Wikipedia, like any encyclopedia, is appropriate for getting an overview of a subject, but may not be the best source for resolving such subtleties. So I would appreciate it if someone could cite a more authoritative source demonstrating the difference between these two, or whether there really is a difference.


title: PDF to doxygen - how to do it?

text: I have a big pdf with the documentation for a project and I need to render this to doxygen (so take each function from the pdf and write it out into doxygen). Any suggestions on how to do this quickly and effectively (other than doing it by hand)?


title: Synchronously write file

text: I am implementing a server in C for a course project. The server should serve more than one client simultaneously. The description of the project states that `fork()` should be used to serve more than one client. Each children should write something to a common file. How do I handle this synchronously? Is there any mechanism like in Java where only one thread can use a function at the same time?


title: How do you map members and their responsibilities to an organization?

text: I'm working on a Django project that tracks arts-related activities, and I'm stuck on the human-resources part of things. (code below) I have a class `Ensemble` that subclasses `Organization`. `Organization` only has one important field, `name`. `Ensemble` has another field, `players` (a many to many relationship). A player is a `Performer` which has two foreign key fields, `individual` and `instrument`. The idea is that a performer is any individual on a particular instrument--so, e.g., I can be one individual that can be two performers: one on guitar, the other on bass. The problem is that not all `organization`s are as clean as this. Some `Organization`s will have dancers, for instance (a dance troup), plus any number of generic `Individual`s who do any number of specific tasks not tracked as a specific class (like `Performer`). So at first I was thinking it would be best to just map `Individual`s to the `Organization` through a many to many relationship, create a `Job` class mapping `Individual`s to a `JobCode` class (which might include a row with something like 'performer'), but that doesn't work well if for instance you want to keep track of _which_ instrument a performer plays for that particular ensemble, or if they play multiple instruments, I would like to be able to make that explicit. That's why the `Ensemble::players` relationship made sense to me. So it seems I have an `Organization` class that will never truly be more than abstract, but I still need to be able to track what type of job an `individual` does for an `Organization`. `Ensemble` only makes sense for mapping `Performers` to an `Organization`, but what about `Teacher`s in a `School`? Again, I would like to be able to make it explicit that a bassoon player is teaching bassoon at the school, and not clarinet (even though they might play both). So I can't just map the `Individual` to the `School` organization, right? Also, this seems like it would be a common problem. Is there a conventional way of dealing with these kinds of relationships? What is the most effective? **Code:**               class Individual(models.Model):         surname = models.CharField(max_length=255)         name = models.CharField(max_length=255)         prefix = models.ForeignKey(Prefix, blank=True, null=True)         suffix = models.ManyToManyField(Suffix, blank=True)         date_of_birth = models.DateField(null=True, blank=True)         phone_numbers = models.ManyToManyField(PhoneNumber, blank=True)         addresses = models.ManyToManyField(Address, blank=True)         user = models.OneToOneField(User, blank=True, null=True)          class Performer(models.Model):         individual = models.ForeignKey(Individual)         instrument = models.ForeignKey(Instrument)          class Organization(models.Model):         name = models.CharField(max_length=255)         founded = models.DateField()         tags = TaggableManager(blank=True)         media = models.ManyToManyField(Upload, blank=True)          class Ensemble(Organization):         players = models.ManyToManyField(Performer)


title: Creating an effective C++ library website and documentation

text: Creating a C++ library also means documenting it so that others can use it, and that documentation can vary dramatically in quality. **How should a website for a C++ library be structured so that it is most effective?** I would frame "most effective" as being divided among three specific groups of library stakeholders, which should each be able to find and learn what they need to participate in and use the library:   1. New users need an excellent, easy introduction, download, setup, and documentation that clearly flows from one step to the next.   2. Seasoned users need a solid reference with fast access to the details they need, and clear information about new updates.   3. New contributors need a how to guide covering the steps they must take to get their contributions into the library. I would like to figure out how to make each very happy with what they see and use. This question is a bit of a cross between professional programming and user experience. For specific examples, Boost is one of the best collections of libraries, but the initial installation, reference documentation, and figuring out how to contribute can be somewhat confusing. On the other hand, I have found cppreference.com and the SGI STL documentation to be very clear and useful with explanations, links, and examples. While the examples are merely opinions and others may differ, it does help give context to the question I am asking.


title: What are the alternate models for remote desktop software?

text: A coworker and I were trying to brainstorm and list the different ways an application developer can write a program enabling a user on one computer to run remotely on another computer while being displayed on their own computer. She suggested all possibilities would fall into only three categories:   * remote desktop software   * hosted service   * appliance I think I understand how an application developer might approach this using the first model (for example, by writing an application that uses a service on the server via a protocol.) I'm unsure how the second model would be different than the first, and I don't understand what the term 'appliance' would mean in this case. What I would like to know is how should an application developer compare these alternatives when designing a strategy for a new application - that will be used remotely?


title: Use constructor or setter method?

text: I am working on a UI code where I have an `Action` class, something like this -                   public class MyAction extends Action {           public MyAction() {               setText("My Action Text");               setToolTip("My Action Tool tip");               setImage("Some Image");           }         }      When this Action class was created it was pretty much assumed that the `Action` class won't be customizable (in a sense - its text, tooltip or image will be not be changed anywhere in the code). Of late, now we are in need of changing the action text at some location in code. So I suggested my co-worker to remove the hardcoded action text from the constructor and accept it as an argument, so that everybody is forced to pass the action text. Something like this code below -               public class MyAction extends Action {         public MyAction(String actionText) {             setText(actionText);             setTooltip("My Action tool tip");              setImage("My Image");          }     }      He however thinks that since `setText()` method belongs to base class it can be flexibly used to pass the action text wherever action instance is created. That way, there is no need to change the existing `MyAction` class. So his code would look something like this.               MyAction action = new MyAction(); //this creates action instance with the hardcoded text     action.setText("User required new action text"); //overwrite the existing text.      I am not sure if that is a correct way to deal with problem. I think in above mentioned case user is anyway going to change the text, so why not force him while constructing the action? The only benefit I see with the original code is that user can create Action class without much thinking about setting text.


title: Which one is better for Offline chat using JMS either RabbitMQ or ActiveMQ?

text: I have a lot worked on the Java Standard Edition; and now I am new comer on the Java Enterprise Edition. Currently I am working on Offline chat module of Enterprise level Application using Spring MVC. Now I have confused in the selection of RabbitMQ or ActiveMQ?Can any one suggest me which one is better for the offline chat. Thanks In Advance


title: Should every member of scrum team be universal?

text: We have a scrum team where there are 5 developers, 2 automated testers, 1 manual tester. Our tasks are completely independent. Shouldn't there be 8 people, every one should be able to do every task: write code, write tests for it, sometimes manually test something?


title: How do I correctly sub-license a library that is under the MIT license?

text: How do I correctly sub-license a library that is under the MIT license. I am using and extending the library. The MIT license states that I am free to sub-license the library. Can I simply state:               <Software library> is copyright <original author> and licensed under the MIT license.          <orignal license>          Extensions to <Software library> are copyright <me> and licensed under the GPL license,      or commercial license if applicable.          <GPL, or commercial license>


title: Participants in Agile retrospective

text: Who should be the participants in retrospective? Will it be only the team members OR should the Product manager, all the stakeholders and dependent teams also participate. I am of the opinion that only the team should meet to discuss in retrospectives, else all team members will not open up. But one of the managers insist that all the stake holders should also be included.


title: What is a software prototype?

text: I understand this site is for programmers, and i have to ask specific coding question. I am doing a software engineering degree and i have been asked to reference at-least 7 books in my definition of prototyping. The best place to ask is here because most of you have probably read books on this and would be able to recommend books to me. I dont mind buying them from Amazon so if you could some books for me that define prototyping or a prototype i would really appreciate it.


title: confusion between these two networking terms: transmission rate vs. propagation speed

text: I read this in _TCP/IP PROTOCOL SUITE_ second edition, written by Behrouz A. Forouzan and Sophia Chung Fegan. > In traditional Ethernet, the minimum frame length is 520 bits, the > transmission rate is 10 Mbps, the propagation speed is almost the speed of > light, and the collision domain is almost 2500 meters. So what is **transmission rate** and **propagation speed**? Why they are not the same?


title: Which language is best for OpenGL?

text: I have the following list of languages:   * C++   * C#   * VB.Net   * D   * Delphi   * Euphoria   * GLUT   * Java   * Power Basic   * Python   * REALbasic   * Visual Basic I would like to know what people think is the:   1. Best ( _most efficient_ ) language to work with OpenGL?   2. Easiest language to work with OpenGL?


title: What is the structure of a team developing a computer game?

text: I wanted to ask if there is a typical structure for a team developing a computer game and, if so, what are the specific roles of the team members. Also, what is the size of such a team (in terms of order of magnitude, 5-10? 10-100? more?). Is there any literature on this topic?


title: What does XXX mean in a comment?

text: What do people generally mean whenever you see `XXX` in a comment. Occasionally, I'll see a comment like this:               # XXX - This widget really should frobulate the whatsit      Of course, I can tell what the comment means, but what does the XXX generally mean? Is it saying "This is a hack" or maybe "Perhaps we should revisit this later"? Or is it saying something else entirely?


title: Wisdom of using open source code in a commercial software product

text: I'm looking at using some open source code in my ASP.NET web app (specifically dapper). Management is not a fan, because open source is seen as a risk that has bitten us before. Apparently previous developers have had to rewrite things after having open-source components fail. The pros seem to be:   * It does a lot of stuff for me that would otherwise involve either lots of boilerplate code or Microsoft's recommended but slower solution (Entity Framework). Cons:   * It's complex enough that if it were to fail suddenly in production, I would be hard pressed to fix it. However, it's in use on a much higher-traffic site than mine, so I don't think it'll end up being a high risk portion of the project. What is the consensus here? Is it unwise to use open source code in my project that I don't know/understand as well as I do my own code?


title: Violating the Interface Segregation Principle?

text: I currently have an interface named `InternalEntityIdTransformer`, which has a `getInternalId` method, that given an external id returns the corresponding internal one. Now I am working on functionality that will need to do the opposite transformation, and go from internal id to external id. Is adding an `getExternalId` method to this `InternalEntityIdTransformer` a bad violation of the ISP? (All places that currently are using this interface only need the `getInternalId` and are not going to care about `getExternalId` at any point.) And if it is, then is is particularly harmful? Should I rather have two dedicated interfaces here? The language used is Java, PHP or C#.


title: Is it good idea to write variable names that match application specific terms?

text: Let us say I am writing a Facebook like application. I write code like below               $this->get_user_friends();       then next morning the boss says that we don't want to call Friends friends anymore, we will call them Pal. Then all the templates are changed but what about the code above? After 2 years when some programmer will have to look into it he is likely to get confused isnt it ? What do you guys really do ?


title: C++ Iterator lifetime and detecting invalidation

text: Based on what's considered idiomatic in C++11:   * should an iterator into a custom container survive the container itself being destroyed?   * should it be possible to detect when an iterator becomes invalidated?   * are the above conditional on "debug builds" in practice? **Details** : I've recently been brushing up on my C++ and learning my way around C++11. As part of that, I've been writing an idiomatic wrapper around the uriparser library. Part of this is wrapping the linked list representation of parsed path components. I'm looking for advice on what's idiomatic for containers. One thing that worries me, coming most recently from garbage-collected languages, is ensuring that random objects don't just go disappearing on users if they make a mistake regarding lifetimes. To account for this, both the `PathList` container and its iterators keep a `shared_ptr` to the actual internal state object. This ensures that as long as _anything_ pointing into that data exists, so does the data. However, looking at the STL (and _lots_ of searching), it doesn't look like C++ containers guarantee this. I have this horrible suspicion that the expectation is to just let containers be destroyed, invalidating any iterators along with it. `std::vector` certainly seems to let iterators get invalidated and still (incorrectly) function. What I want to know is: what is expected from "good"/idiomatic C++11 code? Given the shiny new smart pointers, it seems kind of strange that STL allows you to easily blow your legs off by accidentally leaking an iterator. Is using `shared_ptr` to the backing data an unnecessary inefficiency, a good idea for debugging or something expected that STL just doesn't do? (I'm hoping that grounding this to "idiomatic C++11" avoids charges of subjectivity...)


title: Lead Programmer definition clarification

text: I have been working on PHP and MySQL based web application for more than 5 years now. I started my career as an Intern, and worked my way up through Jr Developer and Software Developer to Sr. Software Engineer (Team Lead), and that's what I am nowadays. I was looking at the link at Wikipedia regarding who is a lead programmer. The link states the following: > A lead programmer is a software engineer in charge of one or more software > projects. Alternative titles include Development Lead, Technical Lead, > Senior Software Engineer, Software Design Engineer Lead (SDE Lead), Software > Manager, or Senior Applications Developer. When primarily contributing in a > high-level enterprise software design role, the title Software Architect (or > similar) is often used. All of these titles can have different meanings > depending on the context. My current job responsibilities are more or less like a _Development Lead_ and to some extent near _Software Architect_ because I usually design the core structure of new products, and manage 2-3 project simultaneously while assisting other teams regarding the structural design of their projects. I am usually on call with clients along with project managers. I code most of the time when my team is stuck somewhere, has a heavy workload, is integrating some third party API, etc. Does what I do qualify for a **Development Lead** title in accordance with my above mentioned job descriptions?


title: Why are floats called "real numbers" in some languages?

text: Some programing languages, notably Pascal, have a type of numbers called "real". However, mathematically speaking, these types aren't real. For them to be "real", these types have to be able to represent **any** real number. Real numbers like 1/3 and irrationals, however, can't be represented in floating point. So why do some programing languages call these types "real"?


title: C#/.Net/Programming talk

text: Lately we have decided in our company to have a monthly 30-60 minutes talk on a subject that relates to C#/.Net programming or anything else that will make us better in our work.   We are currently programming in C# 3.0 with .NET 3.5 in VS 2008. So... I've tried to come up with a topic for the talk (Something that is not too trivial but still could be applied as a guide for better programming, and not just an ad-hoc solution for specific problem) but nothing has come to my mind. I will be more than happy to hear about such topics that could fit my need. Feel free to elaborate or provide references to any resource that would help :)


title: design practice for business layer when supporting API versioning

text: Is there any design pattern or practice recommended for business layer when dealing with multiple API version. For example, I have something like this. http://site.com/blogs/v1/?count=10   which calls business object method GetAllBlogs(int count) to get information http://site.com/blogs/v2/?blog_count=20 which calls business object method GetAllBlogs_v2(int blogCounts) Since parameter name is changed, I created another business method for version 2. This is just one example but it could have other breaking changes for which it requires me to create another method to support both version. Is there any design pattern or best practice for business/data access layer I should follow when supporting API Versioning?


title: What are good words for defining multiples?

text: In databases you might take about one-to-many. This means there's one thing that maps to zero or more others. In this kind of style I'm looking for words that define min/max amounts of things. So far, I have:                       min     max     one      1       1     many     0    infinite     optional 0       1     ???      1    infinite      Is there a single word that fits '???' to mean more than one?   Do you have better alternatives for 'optional'? I'm wondering if there are any conventional names for those concepts?


title: Is 25% to me as sole author a good deal?

text: This is my first contract negotiation. So I've written a program which supports some hardware that the company makes. (The support is important, and most customers will buy it, but the software product is ultimately optional.) It will sell for about $2K/license and they sell 70-80 hardware systems/year. The market here is biomedical research, i.e. the customers are individual research labs in universities and hospitals. The company will be hosting the software (obviously) and it will be part of their marketing pitch. They tell me that a 75-25% split is typical. Really? How does this smell to you guys? What are numbers that you have worked with? Edit: A little more info. I have written an open-source version of this program that has been out about a year. The contract is to write a commercialized version (basically, more features) which I would give to them. They are going to pay me some money up front, then pay me 100% of gross up to a certain amount (low six figures) and after that, 75/25% them/me in perpetuity. They will have all rights and I won't be able to build another product in that category as long as I have a relationship with them.


title: Is there a design pattern or technique in Coldufsion/Java for serializing objects differently depending on customer's desires?

text: I have data available in the form of Structs and Arrays. I need some design pattern advice, which I can use to model this situation into corresponding Coldfusion Components. Here is the data definition I have objects like   * Hotel   * Apartment   * Bus Each object has it's attributes and images. Images have also different types like thumbnails, gallery etc. Attributes may be simple or complex   Simple Attributes like: name, code, id etc   And complex attributes are themselves objects which have it's own Attributes and Images. The second part is Customers. Our customers receive these objects as XML export files. Each customer has it's own requirements. For example some want one kind of attributes and other want other attributes. Some want that one type of images should be exported and some want all image types should be exported.


title: Continuous "Platform" Integration?

text: We have accumulated a large codebase of somewhat-well-document projects, many of which aren't actively being used, but that we want to be able to start using again quickly if necessary. What is the best way to automatically make sure that these projects stay in working condition as the dependencies backing different projects are upgraded? These dependencies tend to be large, open-source and external, such as OpenCV and FFMPEG. Between consecutive versions, they offer Warnings during compilation about the use of recently-deprecated functions; jump more than a few version, though, and updating becomes a significantly more challenging task.


title: Online medical image processing grand challenges

text: I'm currently working on my thesis, and I'm looking for an/some online medical image processing grand challenge(s). I already know this site but I need a challenge which has microscopic image dataset like cells, chromosomes, bacterias, viruses etc with classification or recognation objective. Like karyotyping. Maybe someone is working on this field or his university made a challenge what I'm looking for, and can help me.


title: Coming from QA, how can one land that first development job?

text: I have been in QA for 10 years, trying to get into development for about 5 of them. I have taken classes in C++, Java and C#. I was able to write some tools and unit tests in C# at my current job and (by all accounts) did a good job of it. However, 8 months ago, my employer tasked me with the responsibility of establishing the new QA group. Now I'm doing manual testing and deployment with no promise of returning to development. I have looked at the job boards and there are a lot of jobs for web developers, so what else can I do to get one? I've picked up some books on Ruby on Rails that I plan to work through on the Mac at home, but I'm not sure employers would be interested in anything but commercial web development. Do you have any suggestions on how I can use my experience to get a job as a junior developer? And I mean one that entails programming; the postings I've seen for junior developer amount to doing all the grunt work besides coding. They should just call them "Technical Secretaries".


title: Organizing classes with many properties that need to be iterated through

text: Sometimes when I'm working with a class (usually one that represents a database model), I'll have about 15 different properties on it, usually of different types. These are properties that need to be accessed by the users, as well, so each property will typically need some function like               T getPropertyName();     setPropertyName(T value);      But, it's also extremely valuable for me to be able to iterate through each property **in a particular order** (although, I suppose that "value" may stem from laziness of not having to type each one individually). Is there some logical way to set up this class, so that I could iterate through it in this order? Or am I helpless for organization, and I should just go back to the basics of having 15 private variables, and 15 "getters" and "setters"? As an aside, currently I'm working with Android and Java, so answers pertaining specifically to that would be the most helpful, but seeing how I encounter this somewhat frequently in other languages, too, any solution would be ideal. **Edit:** I've been thinking about using something similar to a Bundle with a list of keys, but I don't know how effective that would really be either.


title: A way to return multiple return values from a method: put method inside class representing return value. Is it a good design?

text: I need to return 2 values from a method. My approach is as follows:   1. create an inner class with 2 fields that will be used to keep those 2 values   2. put the method inside that class   3. instantiate the class and call the method. The only thing that will be changed in the method is that in the end it will assign those 2 values to the fields of the instance. Then I can address those values by referencing to the fields of that object. Is it a good design and why?


title: How Data Transfers differ on Smart Phones: Iphone vs. Android vs. Windows Phone

text: I am interested in how each individual smart phone is allowed to handle data transfers within a third-party app. I am interested in designing apps that allow customers to update, transfer, download, etc. data from their smart phone to their personal computer and vice-versa. (Ranging from just text, to XML, to a Relational Database) I only have experience with the Ipod Touch before and one particular app that maintained all the data on an online server, so to update the data on your pc or iphone you had to go online, are there other ways to do it? Like bluetooth, wireless LAN, USB, etc? I believe Apple has certain policies on this in order to control the App Store and individual Iphones. I suppose each company has a particular policy on how an app is allowed to transfer data to another system, does anyone have a good understanding of this? Thank you.


title: Newbie seeking advice on programming in general

text: need some of you to remember back to a time when you might have been bad at programming... Been at my new job (as a software developer) for a couple of months now, passed probation period. Have very little programming experience (C++ only) and am currently working with asp.net MVC and silverlight. So there's a website the company has been working on and I am joining the effort to make it better, iron out bugs etc. The problem is - learning about a system/website which has already been made, via visual studio. I ALWAYS feel HUGELY overwhelmed, never knowing which part of this line should I look up, and generally having lots of trouble getting the big picture. Visual studio itself is something I'm finding it difficult to get to grips with, let alone the asp.net framework. I get the impression that because my coworkers have more experience than me, they are getting all the good jobs, and I am left with crap to do - stuff which is not even vaguely programming. Meaning they are learning/creating more, and I am learning/creating near nothing. I'm getting demoralised, and too scared to say anything. I'm not stupid, I've read and practiced plenty of the fundamental programming concepts...I'm just bloody scared of this damn framework. I look at it and just feel paralyzed. The result is that I keep asking the older veteran guy of questions, and he is getting irritated, and would rather give me easy/mindless/non programming jobs to avoid wasting time with helping me out. Then when I don't understand something, I'm hesitating about whether or not I should ask him yet, and trying to decide if it would be a waste of time. I'm the kind of person who picks things up slowly, but with a lot of attention to detail. The former I think is making me look incompetent though. Anyone get where I'm coming from please say something helpful....I'm scared of losing my job in a few months or something...


title: Embed Python into Lua?

text: I've found a lot of things about embedding Lua into Python, but I was wondering is is possible to embed Python into Lua? I've searched for a while, and couldn't find anything on it, so maybe some of the StackExchange community knows. It's not a big deal if it _isn't_ possible, but if it is it could be really awesome for a Lua game I am currently working on, using LÖVE. Thanks! :)


title: Technology/Programming mailing lists How do you manage?

text: Email Alerts, Blog /Forum updates, discussion subscriptions general programming/technology update emails that we often subscribe to.Do you actually read them ? or go direct to the source when you find time. Often we might the mail of programmers filled with loads of unread subscription mail from technology they previously were following or worked on or things they wish to follow .Some or a majority of these mail just keep on piling up . I personally have few updates that i wish i read but constantly avoid and keep of for latter and finally delete them in effort keep the in box clean. Few questions come to mind regarding this   * Do you keep such mail in separate accounts?    * Do you read all the mail you have subscribed to?   * Do you ever unsubscribe to any such email if you aren't reading them?   * How much do you really value these email.    * Lastly do you keep your in box clean ? wish to deal with this in a better way.


title: Static and dynamic programming languages

text: Someone who's just getting started in programming asked me about the advantage of different approaches programming languages take. For example, some allow the programmer to omit variable declarations and just use them (like PHP). Others require declaration but not necessarily with a type. And others require a full declaration of the variable (including its type). So what's the advantage of each approach? Why is it better to (not) declare a variable and/or its type? The ones that don't require a type I believe allow for more efficiency for the programmer. You can just take a variable and use it rather than think about what type it may have at the moment of needing it. And potentially you can change its type later on. But is there more to it than that?


title: Dropping database in Grails is too easy. How to prevent accidental drops?

text: I just dropped production database. It happened because I used dbCreate = "create" instead of "update" in DataSource.groovy. I was changing some domain models and wanted to update the database. dbCreate value was empty string (""), and I accidentally changed it to "create" instead of "update". How could I prevent this from happening in the future (grails wise or in general)?


title: Compile-time IOC

text: Has anyone started a project to do IOC at compile time (possibly using Roslyn or Linq MethodInfo emit)? My experience with IOC containers has thus far been great, baring a few small issues   1. Many IOC containers are slow to start up, as much of the resolution logic occurs here   2. It is often hard to ensure that resolution is possible, as compilation no longer ensures that the constructor can be called   3. Often IOC containers add a small overhead to the runtime (some aren't even small, often the ones that start up quickly run slowly) It seems to me that the ideal solution would be to add a compile step to the build chain that adds a Factory class instead of IOC. Has anyone done this before? If not, why not?


title: What's the point of passing a parameter by reference in C#?

text: > **Possible Duplicate:**   >  Why are objects passed by reference? Doesn't C# send the objects themselves? So unless it's some kind of swap function for primitive typed variables - why would I send an object by reference?


title: What was the worst experience you've had with a customer/user?

text: As a programmer, you have to interact with your users/customers in some way to both develop and support the software they pay for. > What was the worst experience you've gotten from those interactions? What did you learn from that experience? Why did this situation happen? How can you to avoid it in the future? I'm also interested in best experiences you have, and why they were different from the worst. and how you can reproduce them.


title: Best practices for logging and tracing in .NET

text: I've been reading a lot about tracing and logging, trying to find some golden rule for best practices in the matter, but there isn't any. People say that good programmers produce good tracing, but put it that way and it has to come from experience. I've also read similar questions in here and through the internet and they are not really the same thing I am asking or do not have a satisfying answer, maybe because the questions lack some detail. So, folks say that tracing should sort of replicate the experience of debugging the application in cases where you can't attach a debugger. It should provide enough context so that you can see which path is taken at each control point in the application. Going deeper, you can even distinguish between tracing and event logging, in that "event logging is different from tracing in that it captures major states rather than detailed flow of control". Now, say I want to do my tracing and logging using only the standard .NET classes, those in the `System.Diagnostics` namespace. I figured that the TraceSource class is better for the job than the static Trace class, because I want to differentiate among the trace levels and using the TraceSource class I can pass in a parameter informing the event type, while using the Trace class I must use `Trace.WriteLineIf` and then verify things like `SourceSwitch.TraceInformation` and `SourceSwitch.TraceErrors`, and it doesn't even have properties like `TraceVerbose` or `TraceStart`. With all that in mind, would you consider a good practice to do as follows:   * Trace a "Start" event when begining a method, which should represent a single logical operation or a pipeline, along with a string representation of the parameter values passed in to the method.   * Trace an "Information" event when inserting an item into the database.   * Trace an "Information" event when taking one path or another in an important if/else statement.   * Trace a "Critical" or "Error" in a catch block depending on weather this is a recoverable error.   * Trace a "Stop" event when finishing the execution of the method. And also, please clarify when best to trace Verbose and Warning event types. If you have examples of code with nice trace/logging and are willing to share, that would be excelent. **Note:** I've found some good information here, but still not what I am looking for: http://msdn.microsoft.com/en-us/magazine/ff714589.aspx Thanks in advance!


title: My father is a doctor. He is insisting on writing a database to store non-critical patient information, with no programming background

text: So, my father is currently in the process of "hacking" together a database using FileMaker Pro, a GUI based databasing tool for his small (4 doctor) practice. The database will be used to help ease the burden on reporting from medical machines, streamlining quite a clumsy process. He's got no programming background, and seems to be doing everything in his power to not learn things correctly. He's got duplicate data types, no database-enforced relationships (foreign/primary key constraints) and a dozen other issues. He's doing it all by hand via GUI tool using Youtube videos. My issue is, that whilst I want him to succeed 100%, I don't think it's appropriate for him to be handling these types of decisions. How do I convince him that without some sort of education in these topics, a hacked together solution is a bad idea? He's can be quite stubborn and I think he sees these types of jobs as "childs play" How should I approach this? Is it even that bad an idea - or am I correct in thinking he should hire a proper DBA/developer to handle this so that it doesn't become a maintenance nightmare? NB: I am a developer consultant of 4 years and I've seen my share of painful customer implementations.


title: One to Many Relationship Django

text: let say I want my User model to have only one location and my Post model to have many location. How Do I design the model? This is what I have in mind so far. Is this going to work? Do I need to create two different Location model for each User and Post model? `class User(models.Model):` `class Post(models.Model):`               class Location(models.Model):      user = models.ForeignKey(User,unique=true)      post = models.ForeignKey(Post)


title: Hallway usability testing and quiet working environment together

text: How can one achieve both the 8th and 12th point, i.e. > Do programmers have quiet working conditions? and > Do you do hallway usability testing? mentioned in The Joel Test: 12 Steps to Better Code?


title: Why is VB so popular?

text: To me, Visual Basic seems clumsy, ugly, error-prone, and difficult to read. I'll let others explain why. While VB.net has clearly been a huge leap forward for the language in terms of features, I still don't understand why anyone would choose to code in VB over, say, C#. However, I still see (what seems to be) the vast majority of commercial web apps from "MS shops" are built in VB. I could stand corrected on this, but VB still seems more popular than it deserves. Can anyone help answer any (or all) of these questions:   * Am I missing something with VB? Is it easier to learn, or "friendlier" than C#? Are there features I don't know about?   * Why is VB/VB.net so frequently used today, especially in web projects?


title: How do you handle specific networking exceptions in Haskell?

text: I have the following to try and connect to a server:               testAddress :: HostName -> Int -> IO (Maybe Handle)     testAddress host iPort = do         let port = PortNumber $ fromIntegral iPort         putStrLn $ "Testing - Host: " ++ host ++ ", Port: " ++ show iPort         result <- try $ connectTo host port         case result of             Left (SomeException e) -> return Nothing             Right h -> do                 putStrLn $ "Connected to " ++ host                 return $ Just h      I made the exception to catch "SomeException", but I know that's not the proper way to do it; as it will catch everything, and you can't handle individual cases. I can't find the names of specific network exceptions though. There doesn't appear to be any documentation for the Network package, and a every example I can find on google just uses "SomeException". If I try and connect to a random host and port, and I don't attempt to catch anything, I get the error: " _*_ Exception: connect: failed (Connection timed out (WSAETIMEDOUT))" But it doesn't seem to give me the exact name of the exception to try and catch. I thought it might be "WSAETIMEOUT", but when I tried catching that, I got a compilation error saying that it couldn't find the constructor for "WSAETIMEOUT". What should I do. I don't want to just catch everything and treat it the same, because then I don't know whats going on. Thank you


title: Object Chain through an Interface

text: Say I have 3+ types of objects:               function Sea() {         var logs = [Logs];         this.getLog = function(ind){return logs[ind]}     }          function Log() {         var bumps = [Bumps];         this.getBump = function(ind){return bumps[ind]}     }          function Bump() {         var frogs = [Frogs];         this.getFrog = function(ind){return frogs[ind]}     }          function Frog() {         this.ribbit = function(){alert("Onomatopoeia!")}     }      So, `Frog` doesn't know about `Bump`, and `Bump` doesn't know about `Log`, but `Log` can access `Bump` and `Frog` directly and indirectly, respectively. Now, let's say that whenever a `Frog` utters a `ribbit`, the `Log` moves slightly (although `Frog` internally doesn't care what happens outside of itself). Now, Mrs. Demeter suggests that I don't do this:               Sea.getLog(5).getBump(2).getFrog(1).ribbit()      It reads nice, but there's some problems. Besides the issue of tight coupling, this method also makes it impossible for the `ribbit` to move the `Log` unless `Frog` ends up getting a reference about `Log`, which means the coupling gets even tighter. However the alternative "one dot" method looks a tad atrocious:               Sea.tellFrogOnBumpOnLogToRibbit(1, 2, 5)      * * * A reasonable solution that has been suggested here (I think) is to create a concise but tightly coupled interface to... interface, with the more business- logicy code:               function SeaInterface() {              var sea = createSea(); //Genesis 1:10              var logInterfaces = [LogInterfaces];         this.getLog = function(ind) {return logInterfaces[ind]}          }          function LogInterface() {              var log = createLog();              var bumpInterfaces = [BumpInterfaces];         this.getBump = function(ind) {return bumpInterfaces[ind]}              //Private method that Frogs will know about internally:         var move = function(){}      }          function BumpInterface() {              var bump = createBump();              var frogInterfaces = [FrogInterfaces];         this.getFrog = function(ind) {return frogInterfaces[ind]}          }          function FrogInterface(log) {              var frog = createFrog();              this.ribbit = function() {             frog.ribbit();             log.move(); //I'm allowed to do this because I'm a simple interface         }          }      That way, I could still use chaining and make the code read well (note: chaining is not a necessity):               Sea.getLog(5).getBump(2).getFrog(1).ribbit()      And the `Log` would still move after a `ribbit`. In the end, it's really just an attempt to minimize the detrimental affects that objects knowing about other objects can cause. Questions:   1. Is there an equally readable or more readable and fool-proof way to achieve the same thing (multiple objects within objects where occasionally manipulating an inner object affects an outer object)?   2. Besides requiring more code, and the fact that the interface itself is tightly coupled (acceptable?), what other problems might arise if I were to interface with the actual object through something like this? Also... does this method have a name? I haven't really seen many approaches like this in the wild, which is what makes me nervous.


title: Android SDK and Iphone SDK limitations

text: I have an idea that would require triggering a call or text message simply by pressing or dialing a certain number. Example: Pressing 2324 on the pin code. Despite it not being your pin code to unlock the device, my application (always running in the back) would detect your code "2324" has been typed in and send a call or text message. Another Example: Holding volume button for 5 seconds and then pressing "2" on pin code lock. This could be another trigger. My question is, how flexible are the iOS and Android SDK's to allow this level of customization? Can I override tone settings via an application (change from Silent to Normal)? Can I close applications? What can't I do? I tried researching this but have not come up with any recent or updated answer. Hoping someone could clarify what I can't/can do with Iphone and Android SDK's.


title: A Web application as a REST API client: how to handle resource identifiers

text: Several concepts related to REST conflict in my head when I try implementing it. I have a REST-ful back-end API system that holds the business logic, and a web application that provides the UI. From various resources about REST (particularly, REST in Practice: Hypermedia and Systems Architecture) I know that I should not expose raw identifiers of my entities, but rather return hyperlinks with `rel="self"`. Consider the example. The REST api has a resource that returns a person:               <Person>       <Links>         <Link rel="self" href="http://my.rest.api/api/person/1234"/>       </Links>       <Pets>         <Link rel="pet" href="http://my.rest.api/api/pet/678"/>       </Pets>     </Person>      The problem arises with the web application. Let's assume it returns a page that contains a hyperlink to browsers:               <body class="person">       <p>         <a href="http://my.web.app/pet/???????" />       </p>     </body>      What should I put into the `href` attribute? How do I keep the API entity URL in the web application to be able to get the entity when a user opens the target page? The requirements seem conflicting:   1. The hyperlink `href` should lead to the web application because it is the system hosting the UI   2. The `href` should have some id of the entity because the web app must be able to address the entity when the target page opens   3. The web app should not parse/construct REST URLs beacuse it's not REST-ful, The mentioned book says > URIs should be opaque to consumers. Only the issuer of the URI knows how to > interpret it and map it to a resource. So, I cannot just take `1234` from the API response URL because as a RESTful client I should treat it as if it was something like `http://my.rest.api/api/AGRIDd~ryPQZ^$RjEL0j`. On the other hand, I must give some URL that leads to my web app and is enough for the app to somehow restore the API's original URL and use that URL to access the API resources. The simplest way is probably just using the API URLs of resources as their string identifiers. But web page urls like `http://my.web.app/person/http%3A%2F%2Fmy.rest.api%2Fapi%2Fperson%2F1234` are ugly. It all seems quite easy for a desktop app or a single-page javascript app. Since they live continuously, they can just keep the URLs in memory together with the service objects for the application lifetime and use them when necessary. With a web app I can imagine several approaches, but all seem weird:   1. Replace the host in the API URLs and keep the result only. The huge downside is that it requires the web application to handle whatever URL the API generates, meaning monstrous coupling. Moreover, it's not RESTful again, because my web app starts interpreting the URLs.   2. Expose the raw ids in the REST API together with the links, use them to build Web App's URLs, and then use the ids on the web app server to find the required resources in the API. This is better, but will affect the web app server performance because the web app will have to go through the REST service navigation issuing a chain of get-by-id requests of some form to handle any request from a browser. For a somewhat nested resource this might be costly.   3. Store all `self` URLs returned by the api in a persistent (DB?) mapping on the web app server. Generate some ids for them, use the ids to build the web app page URLs and to get the URLs of the REST service resources. I.e. I keep the `http://my.rest.api/pet/678` URL somewhere with a new key, say `3`, and generate the web page URL as `http://my.web.app/pet/3`. This looks like a HTTP Cache implementation of some sort. I don't know why, but it seems weird to me. Or Does it all mean that RESTful APIs cannot serve as backends for web applications?


title: Strategy to use two different measurement systems in software

text: I have an application that needs to accept and output values in both US Custom Units and Metric system. Right now the conversion and input and output is a mess. You can only enter in US system, but you can choose the output to be US or Metric, and the code to do the conversions is everywhere. So I want to organize this and put together some simple rules. So I came up with this: **Rules**   * user can enter values in either US or Metric, and User Interface will take care of marking this properly   * All units internally will be stored as US, since the majority of the system already has most of the data stored like that and depends on this. It shouldn't matter I suppose as long as you don't mix unit.   * All output will be in US or Metric, depending on user selection/choice/preference. In theory this sounds great and seems like a solution. However, one little problem I came across is this: There is some data stored in code or in the database that _already_ returns data like this: `4 x 13/16" screws`, which means "four times screws". I need the to be in either US or Metric. Where exactly do I put the conversion code for doing the conversion for this unit? The above already mixing presentation and data, but the data for the field I need to populate is that whole string. I can certainly split it up into the number 4, the 13/16", and the " x " and the " screws", but the question remains... where do I put the conversion code? **Different Locations for Conversion Routines** 1) Right now the string is in a class where it's produced. I can put conversion code right into that class and it may be a good solution. Except then, I want to be consistent so I will be putting conversion procedures everywhere in the code at-data-source, or right after reading it from the database. The problem though is I think that my code will have to deal with two systems, all throughout the codebase after this, should I do this. 2) According to the rules, my idea was to put it in the view script, aka last change to modify it before it is shown to the user. And it may be the right thing to do, but then it strikes me it may not always be the best solution. (First, it complicates the view script a tad, second, I need to do more work on the data side to split things up more, or do extra parsing, such as in my case above). 3) Another solution is to do this somewhere in the data prep step before the view, aka somewhere in the middle, before the view, but after the data-source. This strikes me as messy and that could be the reason why my codebase is in such a mess right now. It seems that there is no best solution. What do I do? **Question** My goal is to figure out how to structure and where to place my unit conversion code within the system. Software system in question is MVC-like (Zend Framework 2 - like) LAMP system. **Specific Example** Right now I have some class that given an `id` at creation time, has a method `getValue()`, which returns `4 x 13/16" screws`. Depending on `id`, different numbers can be produced, but they are still in inches. I should note that some numbers are written with the dividing bar (`13/16"`) and some use decimal notation (`0.8125"`). How could I set up my framework so that I can display such values in millimeters as well?


title: When to use mixins in Ruby

text: I am wondering when to use mixins? I have read about them. Many authors compare them to interfaces, abstract classes, etc. Mixins are modules that are mixed-in and modules are a way to group similar methods, constants and classes together. I have seen examples where a module for math functions is created. It makes sense to group and reuse such functions but should I only mix these in a class if I am faced with an inheritance situation? Should I mix these in anytime I want to use them in a class? Should they be used exactly like interfaces in other languages or are there other subtleties?


title: Would comments increase the chance of being fired?

text: I have had this burning question for a while. If I have a job and I comment my code well, to the point that anybody can now understand my hard work, would it make me less indispensable to the company? From my experience any homework assignment I hand in that is fully commented receives lower grades than, for example, a friend who submits fairly similar code without comments. Almost as if the comments helped nitpick the assignment. I have observed this several times in different classes. I have seen this even in my own tests. One question I commented the code and it was nitpicked until I lost 2 points. Then another question I was unsure and I didn’t comment, I earned full points on it and when I tested the code at home it not only failed to compile but it wouldn’t solve the problem. In the other hand I like comments, it helps me code, but now that I have a job I feel like submitting my code without comments. Any advice on the matter? * * * Since it was mentioned that I might be writing comments that don't contribute positively; here is a sample of something I just coded:               // Deactivate all enemies.     foreach(Transform t in transform)        t.SendMessage("Deactivate");      In this case I do think my comment is helpful, since it won't be clear that `Transform` is actually an `Enemy`, it could be anything really.


title: Is thinking out loud during an interview really the best strategy?

text: In another question I asked recently about best practices for whiteboarding, there was general consensus that thinking out loud while coming up with the answer was the best strategy. Indeed, long moments of silence are awkward. However after recent interviews I have noticed that if my thinking out loud leads to wrong solutions or down the wrong path, that with further consideration I would have seen, interviewers tend to quickly jump in and point out problems with my approach, especially if I stop to pause for a minute. This was not an isolated case, and happened during more than one interview with more than one interviewer. The other thing is that after the interview, on a problem I absolutely bombed, when I sat down and sketched out the problem on a piece of paper in silence I was able to sketch out the solution pretty quickly. Thinking out loud ends up with me spending brain cycles on reflecting on how what I say must be registering with the interviewer and in addition there's a fear of recognizing that I've gone down the wrong path and starting over after having written something on the board wastes a lot of time. Once you've started down one path and realize you've written a lot of junk, you can't undo it, whereas if you've thought quietly about it the interviewer wouldn't have seen the mess and it would have been quicker since whiteboarding a bad idea takes up more time than simply considering a bad idea. I don't want moments of silence but at the same time speaking takes more time, leads to self-consciousness and can lead to interviewer intervention on something I might have figured out myself with just a little more time.


title: What norms/API for monitoring my servers?

text: I have a dozen server applications installed on my customers intranets (they can send http requests over the internet but cannot be called from outside). They're written in various technologies, mainly java and Go. I want them to regularly push information about their state towards a central server which is visible on internet. Some of this information is generic ( _is it ON ?_ ), some is specific (size of a cache in an application for example). The main goal is to be able to make a small web page on which I could instantly check the state of every servers. And maybe later add some kind of notification in case of problem. Obviously I can do this by writing a few dozen lines of code each side (or a little more if I put this data in a database) but in order to ease future evolution, it could be interesting to use some existing norms or libraries. So, what are the current opensource free and light solutions to do this, preferably with no central configuration when I add a server ? I'd prefer a norm over a library.


title: Would "Efficient C++" book be irrelevant now due to compiler improvements?

text: I am planning on purchasing this book to learn more about C++ programming with regards to fast code. However, the book was published in 1999 and I am worried most of it may be irrelevant now due to optimizations that compilers perform. Could anyone please advise? http://www.amazon.com/Efficient-C-Performance-Programming- Techniques/dp/0201379503/ref=cm_cr_pr_product_top edit: Found this book too, albeit also rather old: http://www.amazon.com/Optimizing-C-Steve-Heller/dp/0139774300


title: Checking "instanceof" rather than value using a switch statement

text: Is there some syntax (other than a series of if statements) that allows for the use of a switch statement in Java to check if an object is an instanceof a class? I.e., something like this:               switch (object) {          case instanceof SecondObject:             break;          case instanceof ThirdObject:             break;     }      Sidenote: I recognize that as a design pattern, checking against instanceof and making decisions based on it is not as preferable as using inheritance. To give some context why this would be useful to me, here's my situation: I'm working on a project that involves a kryonet client/server. For communication over KryoNet, you pass objects that it serializes using kryo. Anything added to the object increases the size of these packets,1 so to minimize the network traffic, you keep these objects as light weight as possible. When you receive a packet, you need to know what to do with it, so I'm making this determination based on what type of packet object the passed object is an instanceof. This approach is the same undertaken in the examples included with Kryonet's distribution. I'd love to clean up the hideous class that translates these packets into action, and figure a switch statement would at least make it look moderately more organized. * * * 1As I wrote the statement above, I had doubts about whether what I was saying was accurate. The answer below seems to disagree: > Methods don't add anything to the runtime size of an object. The method code > is not transmitted, and nothing about the methods requires any > representation in an object's state. This is not a sound reason for > instanceof testing, etc. I guess the real issue is I don't know what happens under the hood for Kryo to serialize an object and I was nervous to do anything that increased the bandwidth. Your answers have inspired me to do it with inheritance and add the appropriate methods to the objects. So thank you!


title: Is this a proper use of the word "enumerate"?

text: I'm reading a book that has a section about processes. In it is this sentence: > The next method to enumerate processes is the `GetProcessById` method. This > method does exactly what its name implies: it will take a process ID and > return information about it if it's found. This doesn't sound right to me. Google dictionary has this as a definition > Enumerate - Mention (a number of things) one by one - for ex. "there is not > space to enumerate all his works". I think of enumerate as exactly that, "mentioning", but in the context of walking through a list. If you are getting something by ID, that doesn't sound like "enumerating", that sounds like "retrieving". Am I wrong? Should I broaden my sense of "enumerate"?


title: How do tablespaces differ in DB2 from databases in MySQL or MS SQL Server?

text: In DB2, it seems there is a strong separation between what a _database_ is and what a _tablespace_ is. Where as in MySQL and MS SQL Server _tablespace_ and _database_ seemed to be used synonymously. What are the differences, if any?


title: How is the speed of a page affected?

text: I am trying to develop a single-page web application. I was wondering how big the disadvantages of using jQuery are. I have been told that it makes the application slower, but, as I have seen here, there are only 150ms at every 500 consecutive selections, which seems to me impossible to notice by a user. Others say, that with every jQuery selection, the browser will save jQuery objects in its cache, instead of DOM elements, making the cache bigger, resulting a bigger memory consumption and therefore making the application run slower. Is this true? (I have no idea how the browser's cache is working.) Is jQuery really slowing down such an application? (By this, I mean if the user will ever notice the use of this framework or not.)


title: Is it allowed to distribute a program which source code is under Ms-PL to paying customers?

text: What I want to do is bundle XML Notepad (as is, no modifications) with the installation of our commercial product. Instead of telling the customer "go to http://www.microsoft.com/en-us/download/details.aspx?id=7973 and download XML Notepad". Any one who can offer insight on how to derive the legality of this from the license?


title: Does MSDN follow documentation conventions for .NET, and if so is it publicly available?

text: While browsing the MSDN documentation for the .NET Framework Class Library (FCL) I've always been amazed by how **consistent** and fully documented it is. It's a constant companion when developing .NET applications. Most doubts that arise when using the APIs are covered. The contrast with e.g. the older Win32 documentation is striking. Some examples:   * Documentation for properties always starts out with either _"Gets"_ or _"Gets or sets"_ to specify accessors.   * Type parameters start out with: _"The type of ..."_. Does Microsoft use a documentation convention which is followed for the FCL? If so, is this convention publicly available for me to use as well?


title: Advice on approaching a significant rearrangement/refactoring?

text: I'm working on an application (hobby project, solo programmer, small-medium size), and I have recently redesigned a significant part of it. The program already works in it's current state, but I decided to reimplement things to improve the OO design. I'm about to implement this new design by refactoring a big part of the application. Thing is I'm not sure where to start. Obviously, by the nature of a rearrangement, the moment you change one part of the program several other parts (at least temporarily) break. So it's a little 'scary' to rearrange something in a piece of software that already works. I'm asking for advice or some general guidelines: how should I approach a significant refactoring? When you approach rearranging large parts of your application, where do you start? Note that I'm interested only in re-arranging the high-level structure of the app. I have no intention of rewriting local algorithms.


title: How to update display during large processing job

text: I have an ASP.NET C# application that needs to go off and iterate through a directory of .xml files and do some processing on the data inside them. This is easy enough, but i need to display the result after each .xml is processed, how can this be done? What im really asking here is how do you process a lot of data in a loop that needs to be displayed back to the client even though the server processing has not fully completed. Is this even possible? I could start the big process in a seperate thread and start a js timeout to postback and essentially poll the process but this doesn't sound great and would probably require using static variables to maintain state. Would it be correct to use SessionState / ViewState / QueryString to persist the status of which file ive processed and do away with the loop altogether? Therefore seperate the large job into seperate requests?


title: How do you maintain a common library used by different clients?

text: I am part of a software deveopment team. Originally there were just 2 of us, and two applications. To ease our job we create a set of libraries, handling stuff like GUI, database access, calculation, business rules etc, so that we can reuse them in our applications without implementing them twice. Now the team grew, 6 people and ~5 applications (and growing). The applications use the same library, which are great because we don't have to develop and maintain the same thing more than once. I and the other initial guy developed and are mostly responsible for the library, but other people have access to the code and occasionally update it to fix bugs and add improvements. But soon we notice that the more we grow and the more people can modify the code, there is a risk that "improvements"/"bug fixes" that someone does can unintentionally break someone else's application which depends on the old behavior. On the other hand, assigning one guy to maintain the libraries and make sure modifications won't break anything is not practical because there are many applications, and possibly many improvement requests to be done, and he can't be sure of everything either. How do teams normally manage situation like this? Perhaps by implementing rules on allowed modification? Defining behaviours that shouldn't be changed? There are a lot of libraries in the internet used by a lot of people, for example open-source/free to use libraries like Apache, Castle, etc. How do they make sure that changes won't break existing client codes?


title: Is there a formula to figure out the total execution time of sequential asyncronous processes?

text: I have a set of steps that need to run sequentially over a list of data. However each step only operates on a single piece of data at a time. Because of this, I can run the steps asynchronously. For example I have two pieces of data, and two steps. When step one is done processing the first piece of data, it passes it to step two. Now step one processes the second piece of data while step two is processing the first piece of data. So forth and so on until all of the data has been processed by each step. In contrast, looping through the list of items and executing every sequentially in order turns into the equation:               total_time = (step1 + step2 + ... + stepN) * number_of_items      Given that I know the execution time of each step for a single piece of data, and I know the number of items to be processed, **is there a formula that will tell me the total execution time for processing all the data items asynchronously?** I have written a program (see below) that simulates this process. I'm not entirely sure that it is computing it correctly, but I believe it is close. This was my attempt at figuring out how to solve the problem. I'm including it here to show my understanding of the problem, which may be wrong.               using System;     using System.Collections.Generic;     using System.Linq;     using System.Text;     using System.IO;          namespace ConsoleApplication1 {         class Step : Queue<object> {             public Step(int totalExecutionTime)             {                 _totalExecutionTime = totalExecutionTime;                 CurrentExecutionTime = _totalExecutionTime;             }             readonly int _totalExecutionTime;             public Queue<object> NextStep { private get; set; }             public int CurrentExecutionTime { get; private set; }             public void RunTick()             {                 if (Count == 0)                     return;                 if (CurrentExecutionTime == 0)                     CurrentExecutionTime = _totalExecutionTime;                 CurrentExecutionTime--;                 if (CurrentExecutionTime == 0 && NextStep != null)                     NextStep.Enqueue(Dequeue());             }         }         class Program {             static void Main(string[] args)             {                 int totalItems = 10;                 int[] stepLengths = new int[] { 1,2,5,2,2 };                 if (File.Exists("output.txt"))                     File.Delete("output.txt");                 WriteLine("ASYNC: {0}", TotalTime(totalItems, stepLengths));                 WriteLine("SEQUENTIAL: {0}", stepLengths.Sum() * totalItems);                 Console.WriteLine("DONE");                 Console.ReadLine();             }                  static int TotalTime2(int totalItems, int[] stepLengths)             {                 throw new NotImplementedException();             }                  private static int TotalTime(int totalItems, int[] stepLengths)             {                 var steps = new List<Step>();                 Step prevStep = null;                 foreach(var stepLength in stepLengths) {                     var step = new Step(stepLength);                     steps.Add(step);                     if (prevStep != null)                         prevStep.NextStep = step;                     prevStep = step;                 }                 var first = steps.First();                 for(int i = 0; i < totalItems; i++) {                     first.Enqueue(new object());                 }                 var last = steps.Last();                 var revSteps = steps.Reverse<Step>().ToList();                 var totalTime = 0;                 do                 {                     Display(steps, totalTime);                     revSteps.ForEach(s => s.RunTick());                     totalTime++;                 } while (last.Count < totalItems);                 if (last.CurrentExecutionTime > 0)                 {                     do                     {                         Display(steps, totalTime);                         revSteps.ForEach(s => s.RunTick());                         totalTime++;                     } while (last.CurrentExecutionTime > 0);                 }                 Display(steps, totalTime);                 return totalTime;             }                  static void Display(List<Step> steps, int totalTime)             {                 Write("[");                 steps.ForEach(s => Write("{0},", s.CurrentExecutionTime.ToString().PadLeft(2)));                 WriteLine("]");                 Write("[");                 steps.ForEach(s => Write("{0},", s.Count.ToString().PadLeft(2)));                 WriteLine("] {0}", totalTime.ToString().PadLeft(5));                 WriteLine();             }             static void Write(string fmt, params object[] args)             {                 Console.Write(fmt, args);                 using (var w = new StreamWriter("output.txt", true))                 {                     w.Write(fmt, args);                 }             }                  static void WriteLine(string fmt, params object[] args)             {                 Console.WriteLine(fmt, args);                 using (var w = new StreamWriter("output.txt", true))                 {                     w.WriteLine(fmt, args);                 }             }                  static void WriteLine()             {                 Console.WriteLine();                 using (var w = new StreamWriter("output.txt", true))                 {                     w.WriteLine();                 }             }         }     }


title: Python - defining exit method before importing

text: This breaks nothing (in my experience), but lots of things "don't break anything" and are still wrong.               #! /usr/bin/env python     """Short description of this module."""          def preferred_exit_method(*args):         #code for exiting as desired          try:         import foo         import bar         import eggs     except ImportError as e:         #code code code         preferred_exit_method(e)      So, clearly defining the program's behavior on exit, then using it during the `import` process can't be too terrible, right? But it goes against the oft- cited PEP 8, which states that modules should be absolutely be imported before anything global. It seems like an unrisky proposition, but then there's always something like this:               #! /usr/bin/env python     """Description of module"""          def exit_of_choice(*args):         #code code code         sys.exit(0)          try:         import sys         import other_things     except ImportError as e:         exit_of_choice(e)      Apart from writing code that never needs to do this because it is perfect and never fails at anything, is there a reason besides PEP 8 and "other Python people will be cross with you" not to do this? (well, I'm less concerned with the latter - even though `sys` wouldn't typically fail to import, I still sort of hate that on principle)


title: Which is more effective in coding? Reducing line of code and execution of code?

text: I have this doubt many years. I am wring some code to achieve some functionality. For example I am writing 20 lines of code to achieve the functionality and my co worker writing the code for the same functionality with just 5 lines. Since he used some looping statement to achieve that, but that code will execute around 30 to 50 times. So which is best way of coding? As per my knowledge I always try to reduce coding length as much I can.


title: To load or not to load data for unit tests from external files

text: When unit testing I often find myself debating how much of the data I feed to, and expect back from my units under test, I should include in the actual test files. The tradeoff I constantly struggling with is:   * If a large portion of the test (in code volume) consists of input and output data, it seems difficult to actually read the test, but I can easily see the actual in-and outputs.   * If I load the test data from files, I can easily test a bunch of variations on possible data input, easily reuse test data for multiple tests, but I have to leave the source code to look at another file to see what exactly the inputs are. Is either one of these an anti-pattern?


title: Building a regex builder

text: I am a beginner in programming in general and web development in particular. I am especially bad at regular expressions. Recently I was involved in building a couple of cPanel plugins(Perl-CGI) and that's when I realized how bad I am in regex. As a result, I have decided to build an online regex builder - this will help me to learn regex and help other struggling with regex. I have checked out GSkinner, Rubular and a couple of others like regexpal. It seemed to be a little difficult to use, hence i thought of writing another one. I do not know which tool is best suited for the job. should I write it in Perl or Python? My skill level is between beginner and intermediate in both those languages. What would be a good starting point - building it for the CLI or for the browser? I plan to get a string as an input, ask if the user want to search or search and replace, enter the search string (and the replace string where applicable) and then generate a regex. Would this be the right way to go?


title: AOP concepts explained for the dummy

text: I'm learning Aspect Oriented Programming and have isues understanding concepts. I'm not a bad programmer but my english is bad and can't understand fully the definitions. Can someone explain AOP concepts for dummies: join point, pointcut, weaving etc. For example: **Aspect: a modularization of a concern that cuts across multiple classes.** What that means? Thank you!


title: What scripting languages can be embedded within HTML?

text: Most of scripting languages (like Pythong, Perl, etc) generates the whole HTMLfile. However, PHP code can be embedded within html codes. PHP will process only code between `<?php ?>` tags and ignore other lines. What other scripting languages are available with possibility to be embedded within HTML?


title: C++ Library API Design

text: I'm looking for a good resource for learning about good API design for C++ libraries, looking at shared objects/dlls etc. There are many resources on writing nice APIs, nice classes, templates and so on at source level, but barely anything about putting things together in shared libs and executables. Books like Large-Scale C++ Software Design by John Lakos are interesting but massively outdated. What I'm looking for is advice i.e. on handling templates. With templates in my API I often end up with library code in my executable (or other library) so if I fix a bug in there I can't simply roll out the new library but have to recompile and redistribute all clients of that code. (and yes, I know some solutions like trying to instantiate at least the most common versions inside the library etc.) I'm also looking for other caveats and things to mind for keeping binary compatibility while working on C++ libraries. Is there a good website or book on such things?


title: How do I break down and plan a personal programming project?

text: I've just started a programming job where I'm applying my 'How to code' knowledge to what I'm being taught of 'How to Program' (They are different!). As part of this, I've been taught how to capture requirements from clients before starting a new project. But... **How do I do this for a nebulous personal project?** I say nebulous, as I often find halfway through programming something, I want to expand what my program will do, or alter the result. Eventually, I'm tangled in code and have to restart. This can be frustrating and off-putting. Conversely, when given a fixed task and fixed requirements, it's much easier to dig in and get it done. At work I might be told "Today/This week you need to add XYZ to program 1" That is easy to do. At home (for fun) I want to make, say, a program that creates arbitrary lists. It's a very generic task. How do I start with that? I don't _need_ it to do anything, but I want it to do something. So how do I plan a personal programming project? ### Related: What to plan before starting development on a project?