title: IPC in C under linux

text: I'm building a messaging solution with the followingsetup: all the messages are saved on a DB, two or more reader processes will read from this DB and send data to other process(es) which will send it over the network. My approach is depicted below, The following have 4 sender process with 4 fifos, and 2 readers with 2 fifos reader0 ← read data from DB   reader1 ← read data from DB _sending part_   network_handler0 ← network_handler_fifo0 ← reader0   network_handler1 ← network_handler_fifo1 ← reader1   network_handler2 ← network_handler_fifo2 ← reader0   network_handler3 ← network_handler_fifo3 ← reader1 _receiving part_   network_handler0 → reader_fifo0 → reader0 → write to DB   network_handler1 → reader_fifo1 → reader1 → write to DB   network_handler2 → reader_fifo0 → reader0 → write to DB   network_handler3 → reader_fifo1 → reader1 → write to DB I have few problem with this setup, and please note that the number of processes could be more than that based on the environment, so I could make it 20 readers and 10 network_handlers or it it could as shown above.   1. The size of the buffer is 64K and the message size is 200k, is this small enough to make the write/read to/from fifo atomic?   2. How can make the processes aware of each other, so for example, reader 0 writes to network_handler_fifo0 and network_handler_fifo2, how can I make it start writing on other fifo if the current ones are full or their network_handlers are dea d   3. I thought about making the reader process writing more general in writing, so for example it writes to all network fifos using lock mechanism and stop writing on the one that its process dead, I didn't use it as lock mechanism could slow thing down.  BTW, each network_handler is an SCTP association, so network_handler0 is association 0, network_handler1 is association 1 and so on. Any idea is appreciated. I mean even if I have to change the setup above.


title: How to deal with user interface design and respective feature support in Agile development?

text: In an Agile development process usually the main focus is on User stories, but sometimes a single requirement may span several user stories. For example, the client may request a search page for all users in a forum, and there are several actions that can occur on each user such as ban user, delete user, reset Password, etc. We may divide this feature into at least 4 user stories:   1. Search for users   2. Ban user   3. Delete user   4. Reset password How would the user interface designer implement such a user interface? Should he/she work on the first user story and then start incrementing more features to the UI? However, I think the final UI will be messed up! If he decides to work on the whole feature (search + actions), what if the actions where of low priority and would be implemented several iterations after the search functionality was done?


title: PHP - Auto Code Formatter?

text: I am just wonedering is there a tool/software (ideally free) to do a auto code formatting in the PHP for batch of files (not one by one which i can use the IDE for that) Ideally something like this where i can set the settings and it will do the auto formatting for all the files in side that folder ...etc http://beta.phpformatter.com/ this is very useful but issue is i have to do this one by one copy pasting .. thats why i am looking for another tool..


title: What is the difference between programming for microcontrollers and programming for embedded systems?

text: What is the difference precisely between an Embedded System (like Tegra, Raspberry or similar) and a Microcontroller? I understand there is a difference but I'm finding it difficult to understand. What does one intent when he says: "are you able to develop for microcontrollers"? Does it mean simply program in C/C++ for an embedded system or something more? What is the difference between programming in C/C++ for Embedded Systems and Microcontrollers? If I commonly program for ARM in C/C++, can I say that I can program microcontrollers or can I apply for such a job?


title: Delegate method privately called from delegate itself?

text: One has established design patterns so ingrained in their brain, that when sometimes somebody does something unexpected, it is a revelation. My colleague in an iOS project did call the delegate method from the delegate class itself. That means the delegator was not involved in invoking this method at all. Does this break some kind of principle or design pattern? Technically the delegate method is just like any other method and it is available in the class to call. But we are used to only delegators calling them. Is he breaking a promise of some kind?


title: Why does Facebook convert PHP code to C++?

text: I read that Facebook started out in PHP, and then to gain speed, they now compile PHP as C++ code. If that's the case why don't they:   1. Just program in c++? Surely there must be SOME errors/bugs when hitting a magic compiler button that ports PHP to c++ code , right?   2. If this impressive converter works so nicely, why stick to PHP at all? Why not use something like Ruby or Python? Note -- I picked these two at random, but mostly because nearly _everyone_ says coding in those languages is a "joy". So why not develop in a super great language and then hit the magic c++ compile button?


title: Help me understand a phrase from the "Java concurrency in practice"

text: On a page twelve of "Java concurrency in practice" there is a phrase > "A good specification defines invariants constraining an object's state and > post - conditions describing the effect of its operation." More or less I undersand the phrase untill the word `"post"`, then it becomes a garbage. Can you help please?


title: In what stage of development should comments be written?

text: I'm a student working an internship at a larger company, writing small business apps in C#. I've noticed that I don't comment my code as I write it. Rather, I comment my code when I'm in the debugging stage of development. As I'm tracking down bugs, I'll run across a block that makes me think "hmm...that might confuse someone in the future. I'd better comment that", and I'll add the appropriate comments. All of my comments are done this way. Is this an appropriate way of commenting? Should comments be written as the code is written? Or does it really matter when the comments are written, as long as they adequately explain why this block is used?


title: What's the best practice for async APIs that return futures on Scala?

text: I have started a project to write an async PostgreSQL driver on Scala and to be async, I need to accept callbacks and use futures, but then accepting a callback **and** a future makes the code cumbersome because you always have to send a callback even if it is useless. Here's a test:               "insert a row in the database" in {            withHandler {         (handler, future) =>           future.get(5, TimeUnit.SECONDS)           handler.sendQuery( this.create ){ query =>  }.get( 5, TimeUnit.SECONDS )           handler.sendQuery( this.insert ){ query =>  }.get( 5, TimeUnit.SECONDS ).rowsAffected === 1       }          }      Sending the empty callback is horrible but I couldn't find a way to make it optional or anything like that, so right now I don't have a lot of ideas on how this external API should look like. It could be something like:               handler.sendQuery( this.create ).addListener { query => println(query) }      But then again, I'm not sure how people are organizing API's in this regard. Providing examples in other projects would also be great.


title: Did I Inadvertently Create a Mediator in my MVC?

text: I'm currently working on my first biggish project. It's a frontend facebook application that has, since last Tuesday, spanned some 6000-8000 LOC. I say this because I'm using the MVC, an architecture I have never rigidly enforced in any of my hobby projects. I read part of the PureMVC book, but I didn't quite grasp the concept of the Mediator. Since I didn't understand and didn't see the need for it, my project has yet to use a single mediator. Yesterday I went back to the design board because of some requirement changes and noticed that I could move all UI elements out of the View and into its own class. The View essentially only managed the lifetime of the UI and all events from the UI or Model. Technically, the View has now become a 'Mediator' between the Model and UI. Therefore, I realized today, I could just move all my UI stuff back into the View and create a mediator class that handles all events from the view and model. Is my understanding correct in thinking that I have devolved my View as it currently is (handling events from the Model and UI) into a Mediator and that the UI class is what _should_ be the View?


title: Why no more macro languages?

text: In this answer to a previous question of mine about scripting languages suitability as shells, DigitalRoss identifies the difference between the macro languages and the "parsed typed" languages in terms of string treatment as the main reason that scripting languages are _not_ suitable for shell purposes. Macro languages include nroff and m4 for example. What are the design decisions (or compromises) needed to create a macro programming language? And why are most of the mainstream languages parsed rather than macro? This very similar question (and the accepted answer) covers fairly well why the parsed typed languages, take C for example, suffer from the use of macros. I believe my question here covers different grounds:   1. Macro languages or those working on a textual level are not wholly failures. Arguably, they include `bash`, `Tcl` and other shell languages. And they work in a specific niche such as shells as explained in my links above. Even `m4` had a fairly long time of success, and some of the web template languages can be regarded as macro languages.   2. It is quite possible that macros and parsed typing do not go well together and that is why macros "break" common languages. In the answer to the linked question, a macro like `#define TWO 1+1` would have been covered by the common rules of the language rather than conflicting with those of the host language. And issues like "macros are not typed" and "code doesn't compile" are not relevant in the context of a language designed as untyped and interpreted with little concern for efficiency.   3. The question about the design decisions needed to create a macro language pertain to a hobby project which I am currently working on on designing a new shell. Taking the previous question in context would clarify the difference between adding macros to a parsed language and my objective. I hope the clarification shows that the question linked doesn't cover this question, which is two parts:   1. If I want to create a macro language (for a shell or a web template, for example), what limitations and compromises (and guidelines, if exist) need to be done?   2. (Probably answerable by a link or reference) Why have no macro languages succeed in becoming mainstream except in particular niches? What makes typed languages successful in large programming, while "stringly-typed" languages succeed in shells and one-liner like environments?


title: Request Information from iPhone/Php developers

text: recently I hired a freelancer to develop an iPhone application for my website, this application will get information from the DB of the website, normally I should give to him the access to the DB to take the information needed. The question is, how to let him take the information needed without safely, i.e preventing the danger from hacking or accessing to the DB of the website or do some modifications on it... What can I do ?


title: Patterns for Continuous Integration and DVCS

text: We currently use Subversion and TeamCity, we're going to move to using Mercurial (specifically Kiln as we're FogBugz users). Obviously this will result in changes - hopefully improvements - in our development patterns (all two of us!) but the one issue I'm stuggling with is how to structure things so that we still enjoy the benefits of continuous integration/our CI server (that there are and will remain benefits is a given, discussion of which is outside the scope of _this_ question). With SVN we are committing to a limited number of central repositories - effectively one per project (more or less one Visual Studio Solution) so its easy to trigger a build and to get the reassurance that all the files have been commited and that there are no stray dependencies etc, etc. But if we're going to take proper advantge of mercurial we're going to want to have more repository instances - where I'd expect changes to generally flow towards a definitive "live" repo. The problem I'm struggling with is that the live repo seems to me to be too "late" to trigger my CI builds OTOH one CI build per project per developer is probably excessive (and causes other issues). I think that live is too late because - given that we can/should have more repos (clones of) - live should be deployable whereas we want to be building/running tests (unit at commit, integration at scheduled intervals) on development commits. I'm fishing a bit but that's because one of the things that a central subversion repo gives one (me, with our setup!) is a lot of clarity about what to build when. * * * n.b. I'm not asking about the mechanics of using mercurial with continuous integration - I have that working a treat for a personal project, its patterns and structures and working practice/workflow that I'm trying to get my head round.


Joel Spolsky said in one of his famous posts: > The single worst strategic mistake that any software company can make: > rewrite the code from scratch. Chad Fowler wrote: > You’ve seen the videos, the weblog posts and the hype, and you’ve decided > you’re going to re-implement your product in Rails (or Java, or .NET, or > Erlang, etc.). > > Beware. This is a longer, harder, more failure-prone path than you expect. Have you ever been involved in a BIG Rewrite?   I'm interested in your experience about this tragic topic, and in particular, in any big rewrite that was completed succesfully (if any).


title: Accessing SAP R/3 from Java

text: What do I have to do to write a Java Interface for SAP R/3. I do not have experience with SAP, and they are very slow in their answers, so I just ask here for your experience with them. Can anyone create software that uses SAP for free? Do we have to license the Java Connector? Do we have to become SAP partners? How much is it? Thanks for all information you have.


title: What is a good strategy to develop apps that run in console and as API?

text: I develop quite often scripts that are primary used as a console application but later they are used in other scripts, webservices and other things where it is very convenient, to just import the script and call methods directly rather than using a Process and parsing stdout. The question is now, what is a good design strategy to develop such scripts? I have an example here in python:               def main():        # do stuff        print("Found several results here:")        for foo in bar:            print("result: %s" % foo)               if __name__ == "__main__"():         main()      this one could be easily rewritten to something like this:               def main():        result = some_function()        print("Found several results here:")        for foo in result:            print("result: %s" % foo)               def some_function():        # do stuff        return bar               if __name__ == "__main__"():         main()      But in most of my cases this is not so easy. But how to deal with this problem when the program does quite a lot of output, like different analyses or several steps or the return value of an API function would be something like a list of dict of list of tuples (or even more complicated structures)? Would it be good to encapsulate every step into a single method and run them one after another? What design patterns can be used to write good progamms that can be easily reused as APIs?


title: Defining property and find substitution for copy function of python in cython

text: I want to cythonize a code in python to speed up the code. In the following you can see my attempt to make my python class understandable for cython:               import numpy as np     cimport numpy as np     ctypedef np.double_t DTYPE_T     cpdef double std_G,v_c     std_G=4.3e-9 # Newton's const   in Mpc (km/s)^2 M_sol^{-1}     v_c = 299792.458 #km/s          cdef extern from "math.h":         double log(double) nogil         double sqrt(double) nogil               cdef extern from "gsl/gsl_math.h":         ctypedef struct gsl_function:             double (* function) (double x, void * params)             void * params          cdef extern from "gsl/gsl_integration.h":         ctypedef struct gsl_integration_workspace         gsl_integration_workspace *  gsl_integration_workspace_alloc(size_t n)         void  gsl_integration_workspace_free(gsl_integration_workspace * w)         int  gsl_integration_qags(const gsl_function * f, double a, double b, double epsabs, double epsrel, size_t limit, gsl_integration_workspace * workspace, double *result, double *abserr)          cdef double do_callback(double x, void* params):           return (<ComovingDistMemoization>params).eval(x)                cdef class ComovingDistMemoization(object):          cdef list _memotable          cdef cosmolgy          def __cinit__(self, cosmology, memotable = None):                   if memotable is None:                 self._memotable = []                   self._memotable = memotable              self.cosmology = cosmology          def __call__(self, double z):                      if z in self._memotable:                 return self._memotable[z]                 def eval(z):                      return 1./sqrt(self.cosmology.hubble2(z))             cdef gsl_integration_workspace* w =gsl_integration_workspace_alloc(1000)             cdef gsl_function F                              F.function = &do_callback              F.params = <void*>self              cdef double result = 3, error = 5             cdef double y, err, dist             gsl_integration_qags (&F, 0, z, 0, 1e-7, 1000, w, &result, &error)              y, err = result, error                   gsl_integration_workspace_free(w)                   dist = self.cosmology.v_c * y  #to get proper units, ie to put in the hubble length                  self._memotable[z] = dist                  return dist               cdef class cosmology(object):         cdef comovingdist         cdef public double omega_m, omega_l, h, w, omega_r, G, v_c         cdef double H0, hubble_length         def __init__(self, omega_m = 0.3, omega_l = 0.7, h = 0.7, w = -1, omega_r = 0., G = std_G):                  self.omega_m = omega_m             self.omega_l = omega_l             self.omega_r = omega_r             self.h = h             self.w = w             self.G = G             self.v_c = v_c                  self.comovingdist = ComovingDistMemoization(self)         def __copy__(self):                  return cosmology(omega_m = self.omega_m, omega_l = self.omega_l, h = self.h, w = self.w, omega_r = self.omega_r, G = self.G)              property H0:            def __get__(self):                return 100*self.h  #km/s/MPC              def hubble2(self, double z):             cdef double inv_a             inv_a = 1.+z             return (self.omega_r*inv_a**4 + self.omega_m*inv_a**3 + \                       self.omega_l*(inv_a**(3*(1+self.w))) + (1 - self.omega_m - self.omega_l - self.omega_r)*inv_a**2)*self.H0**2              property hubble_length:             def __get__(self):                 return self.v_c / self.H0              def rho_crit(self, double z):             return 3.*self.hubble2(z)/(8*np.pi*self.G)                   def angulardist(self, double z, double z2 = None):                 if z2 is None:                 return self.comovingdist(z) / (1+z)                  return (self.comovingdist(z2) - self.comovingdist(z)) / (1+z2)      However one of the places that raises error and I couldn't find so far any substitution and my investigation just reached to this point that the `__copy__(self)` function is not supported by cython. I have read that with `pickle.Pickler`, it is possible to provide a substitution for an **instance** of a class but I don't know how it should produce a copy of a class inside the class?? Update: Is it a right way to replace `__copy__` with the following piece of code:               def __reduce__(self):         return (self.__class__, (), self.__getstate__())     def __getstate__(self):         return (self.omega_m, self.omega_l, self.omega_r, self.h, self.w, self.G, self.v_c)     def __setstate__(self, data):         (self.omega_m, self.omega_l, self.omega_r, self.h, self.w, self.G, self.v_c) = data      My second question is about `property`, have I defined the property in cython or I also need to have a `__set__` function as well? My last question, at this point the code get compiled without any error message but when I call an instance of `cosmology` class in python all them return zero. I am wondering whether the wayI have called for instance `cosmology` class in `ComovingDistMemoization` class and vice versa caused the problem and can not pass info between them ?


title: confusion between SVN and code backup by month/date/time whenever i make major or important update to the code

text: I am working on two different project simultaneously where whenever the changes are made we use   1. Tortoise SVN for project A   2. Backed up by folder for Project B (this is done by me on my system) I find SVN good for maintaining the latest code server machine and update it whenever necessary.   For Project A, I happen to make alot of changes to the project A and I am advice not to commit the changes again and again but just a major change all at once.   But since in not alone on project A I tend to make code backs by folder every time I make an important change so I can go back and return if some conflict occurs. But what should I do in case of the project B?   where most I am on the project (as of now).   Should it be SVN or folder backups? The reason I do folder backups for the project B is that   sometimes the build given to the client fails/buggy so instead of making them wait for it to fix   I just go and open the project and compile the last working build and give the executable so they can carry on their work and not wait for me to fix it (may take long). I am working with Delphi on both the projects.


title: MVC content management framework with an admin panel

text: I've lately been developing my own MVC content management system using PHP and, at least in my mind, am a little stuck with the system design. I believe this would apply to building a content management system with an existing MVC framework as well. This is going to be a little difficult to explain, so sorry in advance for the lengthy dilemma. **A little intro to the system:** Currently my routes look a little like this (stored as JSON):               {         "/admin/:controller/:action/:params":"",         "/admin/:controller/:params":"AdminController",         "/admin":"AdminController",         "/:page?/:subpage?":"IndexController"     }      The routes are the keys, the default controllers are the values. If there isn't a default controller the router falls through to the next rule. I've done this to separate the front end of the site from the admin panel. The controllers are all in one directory for the time being, although this is destined to change. They either return a template that's been populated with data from their respective model or simply modify the request they were instantiated with. **The problem:** My problem is with deciding how to implement separate controllers that concern the same model for the front end and the back end in a modular way. For example, I have a page in the admin panel that allows an administrator to enter some private information that's intended only to be accessible on the front end with a username and password. Imagine this is handled by an `InfoController` in the back end, for editing the private information, matched by the route `/admin/info`. What if I wanted to create a route for the front end, for accessing the private information, with the same name as in the admin panel (`/info`)? The problem makes more sense in context with the solutions I've considered, I think. **Solutions I've considered:**   1. My first thought was to append all admin-related controllers with `Admin` \- so `AdminInfoController` and `InfoController` \- but I'm interested in eventually having a modular system where all the routes, controllers and views (and CSS/JavaScript if needed) pertaining to the `Info` model would be in their own directory structure (something like `/modules/info`).    2. With the desire for modularity in mind, I thought about matching routes a bit like `/:module/:controller/:action`, but this would then imply that the admin panel is itself a module, which would need access to all the modules the front end can use. Would that make sense?   3. The design I've thought about the most is to have the admin and front end as two distinguished, core concepts of the framework. They would share modules that contain controllers and views for both. Ultimately I'm looking for input on the best approach here, any alternatives, and whether I'm totally over-thinking this. It feels a bit like I've driven myself crazy with the pursuit of my ideal system design that keeps with the MVC pattern (is it even the right thing for a system like this?). Thanks for reading, I hope it made sense.


title: How do you track what you and your team are working on day-to-day?

text: I'm struggling with how to keep track of what myself and people on my team actually do each day. I get a good broad picture by going over completed cards each week and stand-ups help a bit, but I feel like I don't have a good handle on the day-to-day workings of my team. Cards will stay in progress for days on end without an update at the daily stand-up, and some engineers are my team aren't the most communicative. I've thought about implementing some sort of daily record that everyone fills out (via a mailing list or a shared google doc) but this seems fairly cumbersome and manual. Monitoring GitHub activity does an ok job but can be a little bit overwhelming with how many emails it sends out everyday. I've thought about trying to build a digest system for it, but don't have the time to spare. What strategies have you implemented to stay on top of what your team is doing everyday so that you can measure work on "in progress" tasks?


title: What is meant by an HTML5 application?

text: Since HTML5 is still only a markup language, what is meant when people say "HTML5 application"? Please explain.


title: How to avoid duplication between my issue tracker and the project specification documents?

text: I used to work for a professional consulting firm, and we worked under many different contract terms. When we could get a time & materials project, we ran it with SCRUM and tracked the backlog in our issue tracker system. Most of the time, however, we had to deliver under a fixed price contract. This required a specifications document as an appendix to the contract. So we always ended up batch importing work-items (or worse, manually entering) from the spec. Change orders took a lot of time to make sure everything was in sync, especially towards the end of the project. Is there a methodology or software tool out there **that keeps this whole process DRY**? I've done some searching and I'm apparently not using the right terms. Most of my professional network doesn't do fixed price work. I'd be open to:   1. Switching my bug tracker or buying plugins (currently using FogBugz).    2. Following a different development methodology    3. Writing software to manage the specifications and update the bug tracker and specification document (but this sounds like it will be a lot of work for dubious benefit) Lastly, is this really worth solving? It cost us quite a bit on some projects, but on other projects it didn't end up affecting us.


title: Can I share data between two users in an ASP.NET Application?

text: I have an issue with `Roles.IsUserInRole` function. It take hell amount of time to just check if the logged-in user is in particular role(typ 3-9 sec). I searched to find a solution and arrived on this but I am not sure If I have fully grasped it. What I got from the above, A new derived class is created. Inside that class, there is a list which retrieves all user at once. The next time you check `IsUserInRole`, you do not use the actual IsUserInRole method but rather use the one you overrode in your class. Is this the correct description? Am I on track? **My question is, can data be share between two different users in ASP.NET application?** If yes, will the shared data exist only if there is at least one user logged in. If all users logs out, that shared data is destroyed? My point is this data will be created only one time whenever a user logs in. For all subsequent users they can use this data and check their roles against the list? I need a detailed answer. My application has users and different roles. We are using ASP.NET roles.


title: What is history and concept of code annotation?

text: C# and Java has code attribute and code annotation. I don't know about other languages, but I know the code annotation feature is used to expand language itself. I knew what it is, but I want to know how it developed over time. I want to know its history. How it demanded and how it implemented. Is this possible to implement this in kind of concept on LISP, Smalltalk or C++? And is there a general term to call the concept of annotation?


title: How important is index size when searching?

text: My company has recently began using Apache Solr to search its data. As we learn how to use it we have gone down the path of indexing multiple fields to get the results we need. Most of these are either N-Grammed or Edge-N-Grammed (N-grammed, but only from the edge; for starts-with searching). Gramming by nature takes up a lot of space, which takes more time to search. Space is cheap, but time is less so. Index time is not too important, since a delta-import (only get the changes since last index) is extremely quick and you only pay a penalty on the first import. What we've not been able to determine is what effect the index size has on query times. Obviously a larger index takes longer to search, but the time added by n-gramming a field is difficult to predict. How do you determine whether a field is worth gramming? Can you predict how much longer a query will take when you gram a field?


title: How can we avoid creating duplicate or conflicting functionality when working on an agile team?

text: I'm working in a team where each member is working on an user story. How can we avoid creating duplicate or conflicting functionality? For example, if my user story requires the creation of class A and my team member needs the same functionality and creates a similar class (maybe with a slightly different name), how should we plan our work so that we both move smoothly?


title: Best practices when creating/modeling databases?

text: I learned at the University some steps to model a database:   1. Model the problem using the _Extended Entity-Relationship Model_.   2. Extract the functional dependencies    3. Apply some algorithms to normalize the database ( _3NF_ or _Boyce-Codd_ )   4. Create the database I'm studying **Computer Science** and since I received that course I'm wondering if I always need to do those steps when creating a ~~complex~~ database for an specified problem. For example, do **PHP** / **.NET** / .. programmers always do that? or there are some tools to simplify that process, maybe using another way of represent the problem instead of the _EERM_?


title: Do people who get paid to write code but score low on the "programmer competency matrix" have an ethical duty to find a different kind of job?

text: People advise me to "find a job doing something that you are good at", but the truth is that I don't believe I am good with anything other than just writing code. I don't think that I can design or structure a program though. Don't get me wrong, I'm not the kind of programmer who can't write a fizz buzz program; I'm more like the kind of programmer who can't do much besides getting the job done. It's not that I have a "do the bare minimum" attitude; it's that I'm painfully aware of my limitations as a programmer. For example, implementing a quick sort algorithm is something that I could do only by relying on rote memorization (that is, if I ever find the motivation to spend a good chunk of my day trying to commit the entire algorithm to memory and not just go like "umm, I see, that makes sense, I can see the logic..."). When it comes to structuring and designing an application I feel I'm just as helpless. Since I am unable to see the right answer at the start I just make a judgement call which nine times out of ten I later regret. I still manage to obtain job promotions and praise from my coworkers, so others don't necessarily share my opinions. Objectively speaking though, I simply have neither the learning ability nor the sheer brain power to realistically aspire to be anything more than a 'slightly above average' programmer. I wonder whether I actually have an ethical duty to make room for more talented people and find myself another kind of job, even if I'm fairly confident that I would not find another role I am better qualified for. My question then is "Do average programmers have a place on a team?"


title: How to update a row in database without ID?

text: I've got a table with the following structure :               Col1 | Col2  | Col3     A    | B     | C     A    | C     | B     E    | D     | C      The primary key is (Col1,Col2,Col3). I get the data in another project and display it in view with a grid. When the user edit a row in the grid, for example : A,B,C -> A,B,E, I get (A,B,E) and try to update the database. But I don't know which row must be updated if I don't have the original (A,B,C). What's the proper way to resolve this issue ? Should I create a temporary ID on my second project ? I don't think create an specific ID in the database is a good idea.


title: Why are shortcuts like x += y considered good practice?

text: I have no idea what these are actually called, but I see them all the time. The Python implementation is something like: `x += 5` as a shorthand notation for `x = x + 5`. But why is this considered good practice? I've run across it in nearly every book or programming tutorial I've read for Python, C, R so on and so forth. I get that it's convenient, saving 3 keystrokes including spaces. But they always seem to trip me up when I'm reading code, and at least to my mind, make it _less_ readable, not more. Am I missing some clear and obvious reason these are used all over the place?


title: How to avoid distractions during programming and keep up to date?

text: People always need concentration during work tasks, but i feel programming requires even a higher level. In general my biggest problem is getting distracted by my articles feeds, but i also give it a lot importance to keeping up to date.   1. What are recommended habits or tips to avoid distraction during long programming sessions?   2. How to keep up to date with technologies without investing a big amount of time reading and browsing?  Thanks in advanced.


title: How do you stay focused at work?

text: Sometimes, the things I have to do for my job are interesting and engaging. Sometimes, they aren't. Occasionally, they _really_ aren't. Do you have any particular strategies or tricks for dealing with those dull stretches when your brain would rather be doing anything other than what you're supposed to be doing, particularly when the Internet and its boundless opportunities for interesting Slack beckon?


title: Design patterns and multiple programming languages

text: I am referring here to the design patterns found in the GOF book. First, how I see it, there are a few peculiarities to design pattern and knowing multiple languages, for example in Java you really need a singleton but in Python you can do without it you write a module, I saw somewhere a wiki trying to write all GOF patterns for JavaScript and all the entries were empty, I guess because it might be a daunting task to do that adaptation. If there is someone who is using design patterns and is programming multiple languages supporting the OOP paradigm and can give me a hint on how should I approach design patterns. An approach that might help me in all languages I use(Java, JavaScript, Python, Ruby): Can I write good application without knowing exactly the GOF design patterns or I might need just some of them which might be crucial and if yes which one, are there alternatives to GOF for specific languages, and should a programmer or a team make their own design patterns set?


title: What is the purpose of Console in Sublime text editor?

text: I want to know what purpose does console solve in sublime text 2. This is invoked by pressing Ctrl+Shift+` Is this a kind of debugger, or It just helps you to install packages.


title: Understanding binary numbers in terms of real world objects

text: When I represent a number in the decimal system, I have an intuitive knowledge of what it amounts to. For example take the number '10': I understand that it means 10 apples or 10 people... i.e I can count in the real world. But as soon as the number is converted to any other system, this understanding no longer applies. For example 10 when converted to binary will be 1010...now what does this represent? Is there a way to understand this number 1010 in terms of counting objects in the real world?


title: Joomla Secondary Users

text: ## Background I have a joomla based application. My customers sign up and they register as a user on the site. My customers (primary customers) then have their own space on the site that they can then setup their own customers (secondary customer). ## Question/Problem The problem I am having is that I need to tag each secondary customer to a primary customer. I thought about just creating a new component and having a separate table that includes all the secondary customers. The problem is that I then lose out on all the authentication, session handling and login/logout that the core joomla _users component offers. I then thought about just having all the users in the core _users table and add the primary customer associated with each secondary customer to a field in a profile plugin. This would work for the most part, but this means that primary customers cannot create a secondary customer with a user name that already exists in the _users table. I didn't think this would be an issue, but several of my primary customers (currently only test users) have been confused by the site telling them a username is not available, since they can only see the names of their own secondary customers. Any ideas on some architectural changes I could make to solve this?


title: Architecting persistence (and other internal systems). Interfaces, composition, pure inheritance or centralization?

text: Suppose that you need to implement persistence, I think that you're generally limited to four options (correct me if I'm wrong, please) Each persistant class:   1. Should implement an interface (IPersistent)   2. Contains a 'persist-me' object that is a specialized object (or class) that's made only to be used with the class that contains it.   3. Inherit from Persistent (a base class) Or you can create a gigantic class (or package) called Database and make your persistence logic there. What are the advantages and problems that can come from each of one? In a small (5kloc) and algorithmically (or organisationally) simple app what is probably the best option?


title: Why does Java define homogeneous methods in Matcher and Pattern classes

text: I wonder why java defines homogeneous methods in two distinct classes: java.util.regex.Pattern and java.util.regex.Matcher. For example `split` method defined in `Pattern` class and `replaceAll` method defined in `Matcher` class. I think these two methods are homogeneous, why are they not defined in the same class? Have I understood it wrong? By "homogenous", I mean: `split` and `replaceAll` methods are utilities for String, why not defined in a class?


title: Architecture advice for converting biz app from old school to new school?

text: I've got a WinForms business application that evolved over the past few years. It's forms over data with a number custom UI experiences taylored to the business, so I don't think it's a candidate to port to something like SharePoint or re-write in LightSwitch (at least not without significant investment). When I started it in 2009 I was new to this type of development (coming from more low level programming and my RDBMS knowledge was just slightly greater than what I got from school). Thus, when I was confronted with a business model that operates on a strict monthly accounting cycle, I made the unfortunate decision to create a separate database for each accounting period. Also, when I started I knew DataSets, then I learned Linq2Sql, then I learned EntityFramework. The screens are a mix and match of those. Now, after a few years developing this thing by myself I've finally got a small team. Ultimately, I want a web front end (for remote access to more straight up screens with grids of data) _and_ a thick client (for the highly customized interfaces). **My question is:** can you offer me some broad strokes architecture advice that will help me formulate a battle plan to convert over to a single database and lay the foundations for my future goals at the same time? Here's a screen shot showing how an older screen uses DataSets and a newer screen uses EF (I'm thinking this might make it more real for someone reading the question - I'm willing to add any amount of detail if someone is willing to help). ![enter image description here](http://i.stack.imgur.com/q2vPb.png)


title: Is it my responsibility to code for errors on a completely separate website and domain when redirecting or doing a single sign on?

text: If my application is responsible for redirecting/doing a single sign on to a destination managed by a third party, in general, where should I draw the line for error handling during this process? If an error happens on the other application's end, is it reasonable for my stakeholder to expect the application I am working with to share responsibility for handling these scenarios? Notes:   * I am going to keep solutions limited to those that entail only one request--I am familiar with the "do an xmlhttprequest and see how that fares before doing anything else" approach.    * I am speaking in terms of an enterprise-level application with fairly decent customer traffic.


title: How do I structure code and builds for continuous delivery of multiple applications in a small team?

text: **Background:** 3-5 developers supporting (and building new) internal applications for a non- software company. We use TFS although I don't think that matters much for my question. I want to be able to develop a deployment pipeline and adopt continuous integration / deployment techniques. Here's what our source tree looks like right now. We use a single TFS Team Project.               $/MAIN/src/     $/MAIN/src/ApplicationA/VSSOlution.sln     $/MAIN/src/ApplicationA/ApplicationAProject1.csproj     $/MAIN/src/ApplicationA/ApplicationAProject2.csproj     $/MAIN/src/ApplicationB/...     $/MAIN/src/ApplicationC     $/MAIN/src/SharedInfrastructureA     $/MAIN/src/SharedInfrastructureB      **My Goal (a pretty typical promotion pipeline)**   1. When a code change is made to a given application I want to be able to build that application and auto-deploy that change to a DEV server.      * I may also need to build dependencies on Shared Infrastructure Components.     * I often also have some database scripts or changes as well   2. If developer testing passes I want to have an manually triggered but automated deploy of that build on a STAGING server where end-users will review new functionality.   3. Once it's approved by end users I want to a manually triggered auto-deploy to production **Question:** How can I best adopt continuous deployment techniques in a multi-application environment? A lot of the advice I see is more single-application-specific, how is that best applied to multiple applications?   * For step 1, do I simply setup a separate Team Build for each application?   * What's the best approach to accomplishing steps 2 and 3 of promoting latest build to new environments?   * I've seen this work well with web apps but what about database changes


title: To write or not to write: Frameworks

text: Today some friends and I started discussing frameworks.. Some of us strongly believe that in 99.9% of cases, writing a new framework is a bad idea. We believe that probably some of the millions of frameworks out there should fit our problem, and if not, some hack, API, or configuration should be enough. If not, we think that contributing to some framework, suggest features or something like that should be the best solution. The 0.1% is when none of the frameworks fit to our case. But, some of us say that it is better to have an "internal corporate framework" (for example), because it's faster to fix issues, creates a 100% fit with the app, because of the "learning" factor (when you improve your skills building a framework), etc. I think that to go out coding frameworks like there's no tomorrow is not the right way. I've seen a lot of small teams building their own framework just to spread the word: "we built our own framework, we rule, bro". Generally, the framework is crap, without any documentation, and only works for their own applications. Opinions are opinions, devs are devs, without the intention to start any kind of flame war, I ask: What do you think about that? What parameters you consider when building a framework? What do you think about all this?


title: HTML5/Javascript + Web Services

text: If developing web applications using **ASP.NET MVC** or **Ruby on Rails** make the application use the **MVC design pattern** , then if I build my application using only **HTML5/Javascript + backend webservices** (like WCF rest), then which design pattern will my application follow?


title: What level of detail to use in an interface members descriptions?

text: I am extracting interfaces from some classes in .NET, and I am not completely sure about what level of detail of description to use for some of the interface members (properties, methods). An example:               interface ISomeInterface     {         /// <summary>         /// Checks if the object is checked out.         /// </summary>         /// <returns>         /// Returns true if the object is checked out, or if the object locking is not enabled,         /// otherwise returns false.         /// </returns>         bool IsObjectCheckedOut();     }          class SomeImplementation : ISomeInterface     {         public bool IsObjectCheckedOut()         {             // An implementation of the method that returns true if the object is checked out,             // or if the object locking is not enabled         }     }      The part in question is the `<returns>...</returns>` section of the `IsObjectCheckedOut` description in the interface. Is it ok to include such a detail about return value in the interface itself, as the code that will work with the interface should know exactly what that method will do? All the current implementations of the method will do just that. But is it ok to limit the possible other/future implementations by description this way? Or should this not be included in the interface description, as there is no way to actually ensure that other/future implementations will do exactly this? Is it better to be as general as possible regarding the interface in such circumstances? I am currently inclined to the latter option.


title: Is there a design pattern for chained observers?

text: Several times, I've found myself in a situation where I want to add functionality to an existing `Observer`-`Observable` relationship. For example, let's say I have an `Observable` class called `PriceFeed`, instances of which are created by a variety of `PriceSources`. `Observers` on this are notified whenever the underlying `PriceSource` updates the `PriceFeed` with a new price. Now I want to add a feature that allows a (temporary) override to be set on the `PriceFeed`. The `PriceSource` should still update prices on the `PriceFeed`, but for as long as the override is set, whenever a consumer asks `PriceFeed` for it's current value, it should get the override. The way I did this was to introduce a new `OverrideablePriceFeed` that is itself both an `Observer` and an `Observable`, and that decorates the actual `PriceFeed`. It's implementation of `.getPrice()` is straight from Chain of Responsibility, but how about the handling of Observable events? When an override is set or cleared, it should issue it's own event to `Observers`, as well as forwarding events from the underlying `PriceFeed`. I think of this as some kind of a chained observer, and was curious if there's a more definitive description of a similar pattern.


title: Can lack of "bit parity" between web server and DB server impact performance?

text: I had a meeting with a software vendor today about their recommended infrastructure for deploying a particular application. The application needs two servers: an app server for server web pages (.NET, Windows), and a database (SQL Server). The vendor claimed that these two servers had to have "bit parity". What they meant by this is that if the app server was 32 bit the SQL Server should be 32 bit, or if the app is 64 bit the SQL Server is 64 bit. Otherwise performance will be negatively impacted. This seems ludicrous to me. The servers are independent and only communicate over a network. Network protocols have nothing to do with the "bit-ness" of the processor on either server. Am I in the wrong? Is there a reason where a mismatch actually could negatively impact performance? NOTE: I know that certain apps might run faster or slower in 32 bit vs. 64 bit. But the vendor was saying that the _mismatch_ between web server and DB server causes a problem. This is the statement I'm questioning.


title: Strategy to find bottleneck in a network

text: Our enterprise is having some problem when the number of incoming request goes beyond a certain amount. To make things simpler, we have N websites that uses, amongst other, a local web service. This service is hosted by IIS, and it's a .NET 4.0 (C#) application executed in a farm. It's REST-oriented, built around OpenRasta. As already mentioned, by stress testing it with JMeter, we've found that beyond a certain amount of request the service's performance drop. Anyway, this service is, amongst other, a client itself of other 3 distinct web services and also a client for a DB server, so it's not very clear what _really_ is the culprit of this abrupt decay. In turn, these 3 other web services are installed in our farm too, and client of other DB servers (and services, possibly, that are out of my team control). What strategy do you suggest to try to locate where the bottleneck(s) are? Do you have any high-level suggestions?


title: How can I implement Paxos to develop a project for consensus in distributed systems?

text: I have to implement Paxos algorithm, to experiment on consensus in an asynchronous distributed system. Following is a pdf related to Paxos: http://www.cs.utexas.edu/users/lorenzo/corsi/cs380d/past/03F/notes/paxos- simple.pdf I am confused from where can i start my implementation? I am a Java programmer but my teacher suggested me to use Parsec (http://pcl.cs.ucla.edu/projects/parsec/) , which needs me to code in C. But another problem is, Parsec does not support GUI based implementation. I would like to see my implementation with a GUI. Is there any Java based simulation language for discrete-event simulation where i can implement Paxos algorithm for consensus? If no, then is there any other GUI based simulation language in C to implement Paxos?


title: Arguments for conforming to PSR-2

text: I am trying to convince the lead developer of an open-source project I'm contributing to, to conform to the PSR standards (PSR-2 in particular) created by the PHP Framework Interop Group. He is willing to adopt PSR-0 and PSR-1, but he is opposed to PSR-2. His argument is that PSR-2 is too inconsistent: opening braces for classes and methods MUST go on the next line, but opening braces for control structures MUST go on the same line. I believe that the difference between classes / methods at one side and control structures at the other is not an inconsistency, in fact they are different things. I also believe that consistency between different projects is far more important than treating classes / methods and control structures like they are the same, and that consistancy between projects should outweigh personal preferences... but I can't convince him. Are there any more arguments I can use to try to convince him to use PSR-2, instead of a seperate, yet-another coding standard?


title: Multiple conditions in a function using PSR

text: I'm trying use the PSR conventions in all my projects, but today I view some code of my co-worker and I disagree.               if ($cond == 1 AND $cond == 2) {         // to-do     }      For me, the correct is:               if (($cond == 1) AND ($cond == 2)) {         // to-do     }      **What is the correct use of the PSR?**


title: Is it better to blindly match the project requirements or to match the spirit of the project requirements

text: You know what they're asking for. You know what they really want. However, technically the way they wrote it is with a litmus test of requirements that don't match what they want because they don't understand what they're asking for. Should it be a part of our job to match the spirit of the requirements, or match ridiculous requirements with this gut feeling that the requirements will change once they see the final result? I feel it's more ethical to determine what the user really wants, and find a solution with requirements as a guideline, but often I find others lose patience too much and just wants to give them what they technically ask for.


title: What's a good approach to adding debug code to your application when you want more info about what's going wrong?

text: When our application doesn't work the way we expect it to (e.g. throws exceptions etc.), I usually insert a lot of debug code at certain points in the application in order to get a better overview of what exactly is going on, what the values for certain objects are, to better trace where this error is triggered from. Then I send a new installer to the user(s) that are having the problem and if the problem is triggered again I look at the logs and see what they say. But I don't want all this debug code to be in the production code, since this would create some really big debug files with information that is not always relevant. The other problem is that our code base changes, and the next time, the same debug code might have to go in different parts of the application. **Questions** Is there a way to merge this debug code within the production code only when needed and have it appear at the correct points within the application? Can it be done with a version control system like git so that all would be needed is a `git merge`? P.S. The application I'm talking about now is .NET, written in C#.


title: What would you do if your client required you not to use object-oriented programming?

text: I am writing a program to simulate the activity of ants in a grid (PDF). The ant can move around, pick up things and drop things. The problem is while the action of the ants and the positions of each ant can be tracked by class attributes easily (and we can easily create many instances of such ants) my client said that since he has a background in functional programming he would like the simulation to be made using functional programming. To be clear, the original words from the client is "no class" only, but not "functional programming". So I assume he doesn't mean functional programming and I can do it imperatively. Additionally, I have no prior experience in functional programming. However, I think it's beneficial to focus on this question being particularly about a functional programming requirement than just simply "do it imperatively." How would you handle this situation? Would you try to persuade your client that using object-oriented programming is much cleaner, try to follow what he required and give him poor-quality code, or do something else?


title: Updating an Entity through a Service

text: I'm separating my software into three main layers (maybe _tiers_ would be a better term):   * Presentation ('Views')   * Business logic ('Services' and 'Repositories')   * Data access ('Entities' (e.g. ActiveRecords)) ## What do I have now? In Presentation, I use read-only access to Entities, returned from Repositories or Services, to display data.               $banks = $banksRegistryService->getBanksRepository()->getBanksByCity( $city );          $banksViewModel = new PaginatedList( $banks ); // some way to display banks;                                                    // example, not real code      I find this approach quite efficient in terms of performance and code maintanability and still safe as long as all write operations (create, update, delete) are preformed through a `Service`:               namespace Service\BankRegistry;          use Service\AbstractDatabaseService;     use Service\IBankRegistryService;     use Model\BankRegistry\Bank;          class Service         extends AbstractDatabaseService         implements IBankRegistryService     {         /**          * Registers a new Bank          *          * @param string $name                  Bank's name          * @param string $bik                   Bank's Identification Code          * @param string $correspondent_account Bank's correspondent account          *          * @return Bank          */         public function registerBank( $name, $bik, $correspondent_account )         {             $bank = new Bank();                  $bank                 -> setName( $name )                 -> setBik( $bik )                 -> setCorrespondentAccount( $correspondent_account );                       if( null === $this->getBanksRepository()->getDefaultBank() )                 $this->setDefaultBank( $bank );                       $this->getEntityManager()->persist( $bank );                  return $bank;         }                   /**          * Makes the $bank system's default bank          *          * @param Bank $bank          * @return IBankRegistryService          */         public function setDefaultBank( Bank $bank )         {             $default_bank = $this->getBanksRepository()->getDefaultBank();                    if( null !== $default_bank )                 $default_bank->setDefault( false );                  $bank->setDefault( true );                  return $this;         }     }      ## Where am I stuck? I'm struggling about **how to update** certain fields in `Bank` Entity. **Bad solution #1** : Making a series of setters in `Service` for each setter in `Bank`; - seems to be quite reduntant, increases `Service` interface **complexity** and proportionally decreases it's **simplicity** \- something to avoid if you care about code maitainability. I try to follow **KISS** and **DRY** principles. **Bad solution #2** : Modifying `Bank` directly through it's native setters; - really bad. If you'll ever need to move modification into the `Service`, it will be pain. Business logic should remain in Business logic layer. **Plus** , there are plans on logging all of the actions and maybe even involve user permissions (perhaps, through decorators) in future, so **all modifications should be made only through the`Service`**. **Possible good solution** : Creating an `updateBank( Bank $bank, $array_of_fields_to_update)` method; - makes the interface as simple as possible, but there is a problem: one should **not** try to manually set `isDefault` flag on a Bank, this operation should be performed through `setDefaultBank` method. It gets even worse when you have **relations** that you don't want to be directly modified. Of course, you can just limit the fields that can be modified by this method, but **how do you tell method's user** what they can and cannot modify? Exceptions?


title: Best Upper Bound & Best Lower Bound of an Algorithm

text: I am studying for a final exam and I came past a question I had on an earlier test. The questions asks us to find the minimum value in an unsorted array of integers. We must provide the best upper bound and the best lower bound that you can for the problem in the worst case. First, in such an example, the upper and lower bound are the same (hence, we can talk in terms of Big-Theta). In the worst case, we would have to go through the whole list as the minimum value would be at the end of the list. Therefore, the answer is Big-Theta(n). Is this a correct & good explanation?


title: Dissection of Google indexing services

text: There are more than a few questions that hop into mind when someone thinks about Google's indexing services. Jeff Atwood wrote about them at The Elephant in the Room: Google Monoculture and Trouble In the House of Google. I have two questions:   * How does google index dynamic websites? This site has dynamic pages, `QUESTIONS`, `TAGS`, `USERS`, `BADGES`, `UNANSWERED`, `ASK QUESTION`. The content of these pages is dynamically generated, therefore we access the dynamic content and not the physical files on the server. But how does Google shows every question of the site or other dynamic websites?   * What does Google index and keep on its servers? Does it copy the complete page into its server or just the title, meta tags and body?


title: What is the supposed productivity gain of dynamic typing?

text: I often heard the claim that dynamically typed languages are more productive than statically typed languages. What are the reasons for this claim? Isn't it just tooling with modern concepts like convention over configuration, the use of functional programming, advanced programming models and use of consistent abstractions? Admittedly there is less clutter because the (for instance in Java) often redundant type declarations are not needed, but you can also omit most type declarations in statically typed languages that use type inference, without losing the other advantages of static typing. And all of this is available for modern statically typed languages like Scala as well. So: what is there to say for productivity with dynamic typing that really is an advantage of the type model itself? Clarification: I'm more interested in big / medium sized projects than in quick hacks. :-)


title: Most efficient way for snapshotting Windows (no VM)

text: As the software I'm writing is using instrument I/O, I cannot use virtual machines to test my software in different configurations. Therefore I'm looking for the best way to make snapshots at different states, and restore them quickly for tests. What tools do you use? Right now I see:   * Windows system restore   * Clonezilla (not in love with it, sometimes failed for me)   * Acronis TrueImage What are your advice?


title: Does inserting/removing random characters in a string count as cryptography?

text: I'm making an iOS game. All developers need to determine whether their app uses cryptography or not. My game saves files in the Documents folder. They are .plist files representing dictionaries. They are encoded in base 64. From what I gather, encoding is not encrypting. So we're fine there. However, the _values_ inside the dictionary (after decoding) are a bit tricky. Suppose that your score is `250`. In the dictionary the value is a string like:               @2@5@0@      So for the game to read your score, it removes the `@` characters (and when saving the game, it puts them back). That's just an example. Does _that_ count as cryptography? **NOTE** : I'm not asking about Apple's policies. I mentioned it for context.


title: How to promote an open-source project?

text: First of all, I apologize if this is the wrong section of network to post this question. If it is, please feel free to move it to more appropriate location... Question: I would like to hear your ideas regarding the ways of open source projects being started and run. I have an open-source content management system project and here some questions arise: How should I act? Shall I come up with a viable pre-alpha edition with working front- and back-ends first and then announce the project publicly? Or shall I announce it right away from the scratch? As a developer I know that one should use versioning system like Git or SVN, which I do, no problems there. And the merit of unit-testing is also something to remember, which, to be frank, I am not into at all... Project management - I am a beginner in that, at best. Coding techniques and experiences such as Agile development is something I want to explore... In short, any ideas for a developer who is new to open-source world, is most welcome.


title: Where Can I List My Opensource Project?

text: > **Possible Duplicate:**   >  How can I get the word out about a new (open-source) library I've > developed? I have hosted my latest project, a JVM-based MIDI processor/API called Mjdj MIDI Morph, on Github (here and here). Now I need to bring some interest to it, even if it's negative interest (so I can improve it). I've looked up open source list on Google and end up with such things as this page on Wikipedia, which makes it quite clear that they don't want your project if it's new. Where should I list my project? Short of adwords and talking it up in forums and trade shows, where should I submit my URLs?


title: I released open source code that is useable to other programmers. How do I let them know about it?

text: I have a tiny project (<1k but let's say its <5k of lines). I made it open source and put it on github. I did this once before and I didn't get a single download nor fork but that was very specific and this tiny project is very useable to other programmers. It's open source (let's say LGPL, GPL, public domain or somewhere in between these). What can I do other than let it rot on my computer/online while only I use it? I'll keep this as generic as possible and won't link my stuff.


title: How to make my open source project known?

text: I have a simple project, which enable to record the voice and execute associated commands. I think it can be an interesting and useful project. I don't know how to make it known. I already wrote an article and I published it on hackernews but it wasn't very popular. What can I do to make my project known?


title: How can I get the word out about a new (open-source) library I've developed?

text: I'm finishing up a personal project in which I've implemented a library that I expect others may want to use. Without going into too much detail, the library provides a cross-platform interface for parsing a particular type of file, where none had existed before (at least in this language). The project was fun and rewarding in itself, but I think it would be a shame if it were never considered by other developers due to ignorance. How can I appropriately spread the word about this library? My current plan is to:   * Host a webpage with source, documentation, usage, and/or samples   * Respond to SO questions asking the question "where is this tool?"   * Contact a few key members of the related field and give them a heads up Do you think these steps are reasonable? What else might you do yourself?


title: Getting attention for my open sourced project

text: > **Possible Duplicate:**   >  How to promote an open-source project? I've done quite a lot of work in my spare time on a project that was mostly for my own learning experience and I'm quite pleased with the results. I've used github as a source control management, so the code is already public in a sense. The code in question is a library that is quite specialized in it's application, and pretty well commented and understandable. It would probably be a good resource for students learning about the algorithms being used. What I'm really looking for is the best way to see if there is any audience for what I've done. It's no big deal if there isn't but if there are I'd like people to know about my code, and find it if they are searching for something similar. How to go about this task in the best way? I do have a blog and I intend to introduce the code there, but the audience is so far quite small - mostly co- workers and friends. I'm also unsure about going to specialized sites and advertise, especially as I'm not really part of a community around these types of libraries. Any thoughts and ideas would be greatly appreciated! Thank you for reading. **Edit:** I'm not sure if I should post a link to the project in question on github, or refrain. It's not my intention for this question to come off as advertising. Also, it's amazing how I always find good links _after_ I posted my question. http://producingoss.com/ seems like a good fit.


title: Gremlin -- do I have to know Java/Groovy

text: This is the excerpt from the project's Github page. > _Gremlin provides graph traversal related syntactic sugar to Groovy. Groovy > provides dynamic language syntactic sugar to Java. Realize that anything you > can do in Java or Groovy can be done in Gremlin._ The documentation keeps referring to Groovy & Java. I need to learn it but I am not a member of Java family -- and will likely never be. Can I still learn Gremlin? Can someone point me to some docs/articles that explain Gremlin without assuming Groovy or Java acquaintance?


title: Do You Have To Know CIL To Make A Compiler for .NET?

text: Assume one wants to create a simple .NET language, or slightly more difficult, a compiler for an existing .NET language. Do you absolutely **need** to be familiar with the CIL (Common Intermediate Language) to implement a compiler? And do you have to translate the syntax of your language to CIL by hand? Or is there another (more preferable) way? If not, what is the best way to learn CIL and especially to learn how to translate High-Level code to CIL?


title: What are some examples of "wartiness" making a programming language more useful?

text: From the accepted answer to "Why is Lisp useful?": >  5\. Wartiness. The real world is messy. Pragmatic coding winds up having to > either use or invent messy constructs. Common Lisp has sufficient wartiness > that it can get stuff done. This thought has occurred to me, too. I'm currently developing an application whose backend I chose to write in Haskell, and whose frontend is in PHP. My experience has been that dealing with messy code in PHP is _much_ easier than dealing with messy code in Haskell. However, it's my own code, and my PHP code probably isn't all that bad. A simple example of "wartiness" is PHP's `==` (equality) operator. You know, the type of equality where `'' == 0` is true. Since I'm wary of `==`, I often choose to use PHP's `===` (strict equality) operator instead:               $is_admin = ($gid === 24 || $gid === 25);      However, the above usage turned out to be wrong. The `$gid` value came from the database, and is still a string. This time, the strict equality operator bit me, and I would have saved myself a few minutes by simply saying:               $is_admin = ($gid == 24 || $gid == 25);      Consider another interesting identity:               php> var_dump('0012345' == '12345');     bool(true)      What the heck?! `==` on two strings isn't even string comparison! However, consider if the user is given an ID card that says `0012345`, but the database ID is simply `12345`. Users may have trouble logging in to your application if you chose to use `===`. Sure, you'll get a bug report, and you'll be able to make your application correct rather than relying on this obscure feature. But it'll take more time. I'd rather spend that time outside. It's a really nice day. By contrast, here's an example of wartiness that is _not_ helpful in most cases:               js> parseInt(031);     25      What are some more concrete examples where "wartiness" helps you Get Things Done? Please explain why; don't just list features Haskell doesn't have. Another way of putting it: what are some warty language features to be aware of, and how can we use them to save time?


title: When (and when not) to use Wordpress?

text: For the sake of simplicity, my question is focused specifically on Wordpress instead of focusing on all Content Management Systems including Joomla, Drupal, Concrete5, or you-name-it. Wordpress is becoming ever more popular. You can extend it's feature set with widely available plugins or you can simply design your own plugins if you know a little bit about programming. There are more and more "big" (read well- known, famous or credible) websites that are built using Wordpress. For some examples, take a look at this link. Abraham Maslow once said, "It is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail." I see this tendency within the community of Wordpress developers, and while I value their knowledge and advice on what can be done using Wordpress, I'm afraid that asking them my question about "when to use Wordpress" will only be met with a blank stare that says "is there a time you would not use Wordpress?" This fact is very visible when you do a google search for "when to use wordpress". The situation does improve slightly if you search for "when not to use wordpress". So my question is, in this year 2011, what criteria should best help a web developer determine whether or not to use Wordpress for a given project? **Edit1:**   After some more searching I found this excellent post on this topic: http://wordpress.stackexchange.com/questions/10594/when-should-we-not- recommend-a-client-use-wordpress


title: Mixing jQuery with JavaScript

text: I just asked this question at SO about some bugginess I am experiencing with jQuery and IE8, and someone commented that he was appalled that I would mix JavaScript with jQuery (he has since deleted his comment for some reason). This person had a high reputation, relative to mine (3000+), so I don't want to ignore his criticism. I'm still relatively new to web development, and I mostly work alone, so I wasn't aware that this could be a problem. Why should mixing the two be avoided?


title: svn - when will I see conflicts?

text: I am just starting a new position and using **svn** rather than **git** (my favorite). With **svn** if there are any conflicts will I see them after an svn update or after an (attempt) to svn commit? In other words will an **svn update** merge remote changes into my current (uncommited) working copy? I want to be sure not to mess up before my first **svn commit** if things are not good as I am new to this system! :) Obviously I have also made a manual copy of my new code in case I run into any issues :) fyi, I am on Ubuntu 11.10


title: How can I ensure a method is called only once when using a API?

text: In general, if I am using an API whose methods have side-effects that I only want to occur once, how can I guarantee that my own application only calls them once even if an error occurs before it can register a response? For example, if I am calling a payment processing API once each month for a subscription service, how can I ensure that I don't double-bill if I create a new transaction and the application suffers a fatal error before I get the response from that? It seems like cooperation with the API would be a solution:               t = Transaction.new(user, price, etc);     if(t.persistToLocalDatabase()){ t.beginRemoteProcessing(); }      Is there a way to solve this for the case where I have no control over the API and it begins processing on transaction creation?


title: Is this a good design in C++?

text: Is it a good idea to replace getters and setters with a single function returning a reference? For example, instead of this,               class Person {       std::string name;     public:       std::string GetName() { return this->name; }       void SetName(std::string& toSet) { this->name = toSet; }      };      Is this a good idea,               class Person {       std::string name;     public:       std::string& Name() { return this->name; }     };     ...     ...     Person p;     p.Name() = "Joe"; // Write.      std::string local = p.Name(); // Read.      Does the second code have some problem?      But in C#, methods return object by reference. For example,               class Person     {         string name;         public Person(string _name) { this.name = _name;  }         public string GetName()         {             return this.name;         }         public void SetName(string _name)         {             this.name = _name;         }     };          class Company     {         Person manager;         public Company()         {             this.manager = new Person("Mr. K");         }              // The Person object is returned by reference.         // This is equivalent to "Person& GetManager()" in C++.         public Person GetManager()          {             return this.manager;         }     };     ...     ...     Company comp = new Company();          // Equivalent to,     // Person& p = comp.GetManager();     Person p = comp.GetManager(); // p is a reference to comp.manager     p.SetName("Mr. L");  // This statement changes comp.manager.name          Console.WriteLine(comp.GetManager().GetName()); // Prints "Mr. L"      In the above code, `comp.manager.name` wouldn't have changed if the method `GetManager()` returned `Person` by value. So, this code isn't dependent on return value optimization.   Isn't this code a violation of encapsulation?


title: How to test my knowledge?

text: I am a senior in high school planning on majoring in Computer Science in college. I have been programming for a number of years. However, I have no idea how I stack up to professionals. What would be a way for me to measure my skills in specific languages? I currently use Java, C#, Ruby, and C.


title: Creating database connections - Do it once or for each query?

text: At the moment I create a database connection when my web page is first loaded. I then process the page and run any queries against that conection. Is this the best way to do it or should I be creating a database connection each time I run a query? p.s It makes more sense to me to create 1 connection and use it but I don't know if this can cause any other issues. I am using C# (ASP.NET) with MSSQL.


title: Keeping database connection

text: Say you are developing a desktop application that extensively uses a database, should you have one handle for the database that the entire app references? Or should you open a connection when you need data, get the data, and then close the connection when data isn't necessary.


title: Giving apprentices appreciation of SOLID principles

text: Experienced developers typically have an appreciation of the SOLID (or other) principles - why we have them, how they help, ways of adhering to them etc. This may be as a result of having written poor code in the past, then written good code (where good is adhering to SOLID principles) and seen the tremendous difference it makes, or otherwise had the time and experience to see their value. **How can we begin to instil an appreciation of these things in to apprentice developers?** Currently, at work, I have a group of apprentice developers straight of out college (UK, 18+), with no CS or real programming background. The company has a decent training programme for them to run through, but I feel it lacks the induction to writing high quality code that we would eventually like for them to produce. My current approach to teaching them about these things is to flag it up in code reviews when I see it. For example, when I see a class (or function) which has more than a single responsibility, I do my best to explain the single responsibility principle (why we have it, how it helps), show them where the multiple responsibilities in their code lay, then talk to them about how they might separate that out. However, that approach doesn't seem to be sticking. I'm still seeing plenty instances of exactly the same thing I flagged up in code review. **Are there better ways of explaining and giving appreciation of the SOLID principles? Or is this simply something which comes with time and experience?**


title: Traffic splitter on a single server for 50+ krps

text: I am building a "splitter" for web traffic: a web server that will receive an HTTP request, forward it to two backend servers, choose the best response (for which it needs to parse all of them) and return it to the original requestor. (Just to clarify: it is not a proxy with several backends; each request is forwarded to all backends, and then only one response is returned.) It will need to handle at least 50 thousand requests per second (or 50+ krps) on a single server. Together with a colleague we have built several versions of the splitter. Here are the results:   * Node.js (`http` library): goes up to 6.9 thousand requests per second (6.9 krps).   * Go (`net/http` library): up to 12 krps.   * Erlang (`misultin` and `lhttpc` libraries): up to 7.3 krps.   * Clojure (`http-kit`): 13 krps. None of them are even close to the requirement. According to e.g. the single query of the Web Framework Benchmarks by TechEmpower, which might be roughly equivalent to the splitter, there is room for improvement. The big question is, what should we try next? **Technical details:** The server should handle at least 50 krps on a single server, standard hardware. The requests are POST messages with JSON-encoded bodies of about 1~3 KB, and the responses have similar size. Each request does not need to be parsed, but it can be passed along as is; in the response, at least one specific JSON field needs to be parsed. Each request has a very strict timeout that is between 80 and 450 ms, depending on the URL; if any backend takes longer than that, the server should forget about it and use the remaining backend. If no valid responses are received in time, the server will respond with a 204 No content. **Testing details:** For simplicity, let us say that all requests are all coming from an HAProxy server in front of it, so an Apache `ab` or `wrk` load tester is appropriate. It will run on Amazon EC2, so it should use multiple cores efficiently. For reference let us say it is a c3.2xlarge instance. Both backend servers should reside on a different machine than the splitter (possibly two separate servers, if needed), and ideally the load tester should also be on another machine. It is important to ensure that neither the load tester nor the backends are the bottlenecks here, which is as simple as load testing one of the backends directly and verifying that it gives much better results than the splitter. Results for `wrk` testing the servers returning a constant string:   * Node.js (`http` library): 43 krps.   * Go (`net/http` library): 73 krps.   * Erlang (`misultin` and `lhttpc` libraries): 59 krps.   * Clojure (`http-kit`): I don't have the number, but > 20 krps. Some days ago I asked a question about a splitter-like service in Go, and the answer there allowed me to go up to 6 krps. Further optimizations increased this number to about 12k, although I am not sure that the results will hold in the general case. For instance: I was returning a constant response and not parsing the JSON responses. I am not really sure if our results are reasonable, or if we should be getting much better results with the frameworks we have tried. According to the Web Framework Benchmarks, C++ (with CPoll based C++ server pages) and Java (multiple frameworks) are kings of the game when it comes to rps; but given the effort required to set up, build and test the services in each new framework we want to be sure that we are not getting into any dead ends here. The benchmark above is not really equivalent to our problem; and it is hard to get rps numbers for this kind of proxy-like traffic. I should clarify that it _should_ be possibly to reach the goal, since HAProxy can forward 33 krps with a single core; using the 8 cores in a c3.2xlarge instance, and with anything remotely resembling linearity, it should be within the realms of possibility to reach 50 krps doing two forwards of each request. Writing a multicore web server in C is not in our plans except as a last option, though. This question has been interpreted as too broad on StackOverflow and here by eager editors. So I will reformulate with a clear, straightforward question: Have you built or read about anything similar, with peak performance numbers? (For instance a proxy server for HTTP traffic, even though it would only forward each request to one backend.) Please detail in what language, with what library or framework, and how many requests per second were obtained with a single server.


title: ASP.NET MVC create a draft without persisting to DB

text: I have a requirement to allow users to suggest updates to their profiles on a site I'm working. They would be able to view their profile details, then click on and "edit" button, which would basically make a copy of all their data contained in a handful of one-to-many related DB tables. They can then add or remove items and update various text fields before saving the draft. Upon saving, an administrator would have to approve this change before the new data is actually published onto the live site. I currently have an identical set of tables for live data and drafts (and history, but that's not important). My difficulty is that the client doesn't want an actual draft entry created in the drafts db structure until the user has hit "save". A user would be able to perform CRUD operations against all the data, including uploading new images, but I am not allowed to touch the DB unless they're ready to commit these updates. My great problem is that I have no idea how to begin developing what seems to the client to be a very simple thing, even though it's technically quite challenging. I also can't seem to make the client understand that hitting the "Cancel" button next to the save button would remove the entry plus all its related data from the DB, making the problem moot in my humble opinion. So, the question is such: is there a way to phrase my objection in such a way that the client can understand what I'm getting at. Or failing that, what would be a good way of developing such a session-stored object?


title: Keywords for defining constructs in programming languages

text: I'm designing a language conceptually similar to Go. In Go, for example, the keyword `func` is used for defining functions:               func abs (a int) uint { ... }      Same for defining types. However, I was thinking of a grammar that doesn't consider these keywords. For example:               abs (a int => uint) { ... }      Or, for structures:               Tree {size int; age int}      What's wrong with such a syntax? Are there some potential problems that could be encountered? For example, I thought that if there was a construct that would use the same grammar as a struct, such as an interface, it would be vague (is this a struct or an interface)?


title: Creating a compiler in .net

text: I have read about compiler construction some concepts. What is understood is that   1. You need a lexer that divides your program statements into tokens.   2. You need to check and identify tokens into known types.   3. You have to create a grammar and check if your tokens fit between the grammar defination.   4. You have to create a AST syntax tree . I am stuck at the parser and AST step , I am trying to create a simple language compiler. How can I create a parser and AST for simple statements like var a = 10 * 20; ... etc.


title: Ongoing confusion about ivars and properties in objective C

text: After almost 8 months being in ios programming, I am again confused about the right approach. Maybe it is not the language but some OOP principle I am confused about. I don't know.. I was trying C# a few years back. There were fields (private variables, private data in an object), there were getters and setters (methods which exposed something to the world), and properties which was THE exposed thing. I liked the elegance of the solution, for example there could be a class that would have a property called `DailyRevenue`...a float...but there was no private variable called `dailyRevenue`, there was only a field - an array of single transaction revenues... and the getter for `DailyRevenue` property calculated the revenue transparently. If somehow the internals of daily revenue calculation would change, it would not affect somebody who consumed my `DailyRevenue` property in any way, since he would be shielded from getter implementation. I understood that sometimes there was, and sometimes there wasn't a 1-1 relationship between fields and properties. Depending on the requirements. It seemed ok in my opinion. And that properties are THE way to access the data in object. I know the difference betweeen private, protected, and public keyword. Now lets get to Objective-C. On what factor should I base my decision about making something only an ivar or making it as a property? Is the mental model the same as I describe above? I know that ivars are "protected" by default, not "private" as in C#.. But thats ok I think, no big deal for my present level of understanding the whole iOS development. The point is ivars are not accessible from outside (given I don't make them public.. but I won't). The thing that clouds my clear understanding is that I can have `IBOutlets` from ivars. **Why am I seeing internal object data in the UI?** * _Why is it ok?_ * On the other hand, if I make an `IBOutlet` from property, and I do not make it readonly, anybody can change it. **Is this ok too?** Let's say I have a `ParseManager` object. This object would use a built in `Foundation` framework class called `NSXMLParser`. Obviously my `ParseManager` will utilize this `NSXMLParser`'s capabilities but will also do some additional work. Now my question is, **who should initialize this`NSXMLParser` object and in which way** should I make a reference to it from the `ParseManager` object, when there is a need to parse something. **A) the`ParseManager`** - **1)** in its default init method (possible here ivar - or - ivar+ppty) - **2)** with lazyloading in getter (required a ppty here) **B) Some other object** \- who will pass a reference to `NSXMLParser` object to the `ParseManager` object. - **1)** in some custom initializer (`initWithParser:(NSXMLPArser *)parser`) when creating the `ParseManager` object.. A1 - the problem is, we create a parser and waste memory while it is not yet needed. However, we can be sure that all methods that are part of `ParserManager` object, can use the ivar safely, since it exists. A2 - the problem is, the `NSXMLParser` is exposed to outside world, although it could be read-only. Would we want a parser to be exposed in some scenario? B1 - this could maybe be useful when we would want to use more types of parsers.. I don't know... I understand that architectural requirements and language is not the same. But clearly the two are in relation. How to get out of that mess of my? Please bear with me, I wasn't able to come up with a single ultimate question. And secondly, it's better to not scare me with some superadvanced newspeak that talks about some crazy internals (what the compiler does) and edge cases.


title: What are best practices when switching between projects/coming back to projects frequently?

text: The nature of my job is that I have to switch back and forth between projects every few weeks. I find that one of the biggest impediments to my productivity is the ramp-up time to getting all the relevant pieces of code "back in my head" again after not seeing it for a period. This happens to a smaller and larger extent for briefer breaks / longer breaks. Obviously, good design, documentation, commenting, and physical structure all help with this (not to mention switching between projects as infrequently as possible). But I'm wondering if there are practices/tools that I may be missing out on. What are your specific practices for improving on this?


title: Notify client about changes in database in java

text: I've been searching around for the answer to this question, but haven't been able to find a solution. I am working on a distributed client-server system that uses TCP. The program's functions is to transfer money to an from the server, but also between the clients, a sort of MobilePay. When one client wishes to transfer money to another client, that client will need to accept the transfer before it is succeeded (one of the systems requirements). So, my problem is, i would like the client to get notified (preferably through a message dialog) whenever a transfer is ready to get accepted. All the payments/transfers is stored in a SQL table. I would like the client to get notified when there is a pending payment/transfer in his/hers name, that is, when a new row (with the clients name as receiver) in the transfer table is added, in stead of the client needing to actively see if there is any pending payments (as it is now) Can anybody help my how to get around this problem Thanks in advance Best regards


title: Is it bad interview practice to have candidates write a linked-list implementation?

text: Reading this site and SO I've seen many stories of interview questions and answers saying a candidate had to implement a linked list from scratch. Usually this is a "gimme" exercise for programming role candidates like writing FizzBuzz. The idea is that if the candidate can't do this, they can't program and should be rejected almost immediately. However, I can't help but think this could be a poor practice for the following reasons:   * Modern higher level languages like C# and Python natively use lists extensively; writing your own linked list object would be only required under unusual circumstances and even then probably ill-advised.    * Lower level languages like C++ have standard libraries with iterators/list containers and objects.    * In light of the first two points, coders can go years without even thinking about implementing a list (linked, doubly-linked, etc) themselves. Some may not even really see such things since college days.   * Computing power also isn't the factor it was years ago, so efficiency via pointers isn't the issue it used to be (in general).    * A simple web search of something like "linked list example" would bring up plenty of code examples that could just be memorized and spat back out, not really indicating the true competence of the applicant.  I should say that using a linked list to lead to **open-ended** questions/discussions of candidates' problem solving/critical thinking abilities is mostly likely a really good interview practice. Any way an interviewer can really see what an applicant is like and how they think is massively beneficial. I think this binary approach of "no linked list code, no job" for programmers working on a desktop or web application is a bit outdated. It could also be quite harmful; a candidate who can't remember how to properly work with the head of a list could be an otherwise excellent coder and co-worker and be lost in the mix. Thoughts? **EDIT** : There are many (good) comments suggesting that whether this is a good or bad question to ask depends on the context of the job. I strongly agree, so let me rephrase this question: Implementing a linked-list is a common interview question for a wide range of coding jobs, similar to questions like FizzBuzz or writing a recursive function for calculating factorials. Does this question have enough utility to be used commonly for evaluating programming candidates across the board? Or should considered a bad question to ask except for "Senior Developer, Embedded Linked Lists Team" positions?