Notation/Meta Language To Express An Algorithm

I need to learn a notational language, so I can express and possibly prove the correctness of what I believe to be a complicated algorithm that distributes a credit adjustment across multiple water bills in issue date descending order. But I cannot tell what that notational language should be. Each bill has three consumption tiers, 1-30, 31-60, and over 60. Each tier is associated with a different water and sewer rate. The higher the tier, the higher is the rate. Two water bills each have 100ccf consumption, which means each bill is billed like this. That is it's distribution across tiers 1, 2, and 3 is tier1 = -30, tier2 = -30, and tier3 = -40. In case it is not obvious, billing takes place from lowest to highest tier, so crediting takes place from highest to lowest tier. If I apply a -170 consumption credit, the first bill consumes -100ccfs. It is the remaining -70 ccf credit to be applied to the second bill that gets crazy. -40 of it has to be credited at tier3 and the remaining -30 at tier2. Nothing is left over for tier1 (second bill). I know this is absolutely correct distribution, because I've consulted the oracles in our municipality. They know what they're talking about. With -70 left (held in one variable) and the second bill's original consumption (held in a separate variable), I subtract the value of the sum of tier1's and tier2's cutoffs (60ccf) from 100ccf (the consumption when the bill was issued). I want to prove why that is right. I'm not content to say "Hey, I fooled around until I got a nice answer." Any ideas or help would be appreciated.


Why does C use the asterisk for pointers?

I'm just now learning about C. I find it odd that the creators chose the asterisk (`*`) as the symbol for pointers rather than a symbol that actually _looks_ like a pointer (`->`). Considering how confusing dereferencing and function pointers can be, is there a historical --or even practical-- reason for using the asterisk?


Best practices for implementing MVVM and MVC in delphi Pascal

I'm a Delphi pascal programmer, I use the latest Embarcadero delphi XE, and I would like to take advantage of design patterns such as Model view controller and model view view-model. However, there doesn't seem to be much on the web about the best practices for doing this in pascal. Most of the examples that I can find are in C# and some of the language features are not present in pascal, which means I may have to find ways to implement those features. I'm trying to adapt code from this article here I'll list the issues that I'm facing   * **Nullable types** Pascal does not have nullable types as C# does so I have created my own.               TNullable<T> = record         strict private           fHasValue : boolean;           fValue : T;           function GetValue:T;           procedure SetValue(newValue : T);         public           property HasValue : boolean read fHasValue;           property Value : T read GetValue write SetValue;           procedure SetToNull;         end;      in the implementation section               function TNullable<T>.GetValue:T;     begin         if fHasValue then         begin             Result := fValue;         end         else raise Exception.Create('Value Not Set');     end;          procedure TNullable<T>.SetValue(newValue : T);     begin         fValue := newValue;         fHasValue := true;     end;          procedure TNullable<T>.SetToNull;     begin         fHasValue := false;     end;        * **Get/Set for properties** Now that I have a nullable type I can create nullable properties However it comes with some code smells for example if i create                   TFoo = class           private             function GetBar:TNullable<Integer>;             procedure SetBar(x:TNullable<Integer>);           public              property Bar : TNullable<Integer> read GetBar write SetBar;      in the implementation section               function TFoo.GetBar:TNullable<Integer>;     begin         if **valueExists** then         begin             Result.Value := **the value**         end else         begin             Result.SetToNull;         end;     end;          procedure TFoo.SetBar(x:TNullable<Integer>);     begin         if X.hasValue then         begin             //Store/show value here         end else         begin             //handle null assignment here         end;     end;      This is fine but when it comes to use these properties I can't just use myFoo.Bar.Value := 1; I have to use               var          myBar : TNullable<Integer>;     begin         myBar.Value := 1;         myFoo.Bar := myBar;     end;      Which is a bit messier. I suppose there may be nothing I can do about this.   * **Circular References** I like to separate classes into different units. ie: ![structure](http://i.stack.imgur.com/XD75V.png) keeping the user interface separate from the control logic and the model and data logic layer. I can have a situation where 2 classes can reference each other. While this is a situation that for the most part I would like to avoid, there are occasions where this is needed. for example               unit u_A;          interface          uses       u_B       ;          type        TA = class         public            Foo : TB;       end;          implementation          end;      and another unit               unit u_B;          interface          uses       u_A       ;          type        TB = class         public            Foo : TA;       end;          implementation          end;      This code is broken because the two classes include each other and this can not be done in pascal. This is not such a problem in C#. Solutions that I can think of: 1. include both classes in the same unit, although this is a problem if I do not think this suits the design. 2. Create another parent interface for B and inherit B from that, then this gets around it. Although this is messy for such a simple task.   * **Static classes** There aren't any static classes in Delphi, these are useful for control classes.   * **Best Container classes to use in Delphi** I'm currently using TList and TObjectList in Generics.Collections They were introduced in Delphi XE I hope these are the best to use since delphi 7 didn't seem to have any good options. I'm still thinking about event handlers and any issues that may arise there. Perhaps there are some other issues that I have not thought of yet. Thanks for any advice.


Is this a decent use-case for goto in C?

I really hesitate to ask this, because I don't want to "solicit debate, arguments, polling, or extended discussion" but I'm new to C and want to gain more insight into common patterns used in the language. I recently heard some distaste for the `goto` command, but I've also recently found a decent use-case for it. Code like this:               error = function_that_could_fail_1();     if (!error) {         error = function_that_could_fail_2();         if (!error) {             error = function_that_could_fail_3();             ...to the n-th tab level!         } else {             // deal with error, clean up, and return error code         }     } else {         // deal with error, clean up, and return error code     }      If the clean-up part is all very similar, could be written a little prettier (my opinion?) like this:               error = function_that_could_fail_1();     if(error) {         goto cleanup;     }     error = function_that_could_fail_2();     if(error) {         goto cleanup;     }     error = function_that_could_fail_3();     if(error) {         goto cleanup;     }     ...     cleanup:     // deal with error if it exists, clean up     // return error code      Is this a common or acceptable use-case of `goto` in C? Is there a different/better way to do this?


Were you able to implement design patterns in tight deadlines?

I am wondering, in tight deadlines, who has time to implement design patterns? It is a lot more work and programming overhead to get it right the first time and within time frame. I know that it has long term advantages, but were you able to implement any design pattern correctly when the client is sitting on your head and pressure is growing. I think once your first version is released and you have plenty of time for the next release, than you can think of improving code quality and manageability with design patterns.


Why disallow int-to-short assignment but allow multiplication and other math?

In Java, the following code does not compile:               int val = 1;     short shortVal = val;  // Incompatible types      Anyone know why Java chooses to complain about this assignment, instead of simply truncating, when an integer × integer is also likely to overflow? To illustrate:               int val = 46340;     int result = val * val;                    // 2147395600     System.out.println(result);     int overflowVal = 46341;     int result2 = overflowVal * overflowVal;   // -2147479015     System.out.println("Quietly overflowed: " + result2);


Win32 and Win64 programming in C sources?

I'm learning OpenGL with C and that makes me include the `windows.h` file in my project. I'd like to look at some more specific windows functions and I wonder if you can cite some good sources for learning the basics of Win32 and Win64 programming in C (or C++). I use MS Visual C++ and I prefer to stick with C even though much of the Windows API seems to be C++. I'd like my program to be portable and using some platform-indepedent graphics library like OpenGL I could make my program portable with some slight changes for window management. Could you direct me with some pointers to books or www links where I can find more info? I've already studied the OpenGL red book and the C programming language, what I'm looking for is the platform-dependent stuff and how to handle that since I run both Linux and Windows where I find the development environment Visual Studio is pretty good but the debugger gdb is not available on windows so it's a trade off which environment i'll choose in the end - Linux with gcc or Windows with MSVC. Here is the program that draws a graphics primitive with some use of windows.h This program is also runnable on Linux without changing the code that actually draws the graphics primitive:               #include <windows.h>     #include <gl/gl.h>          LRESULT CALLBACK WindowProc(HWND, UINT, WPARAM, LPARAM);     void EnableOpenGL(HWND hwnd, HDC*, HGLRC*);     void DisableOpenGL(HWND, HDC, HGLRC);               int WINAPI WinMain(HINSTANCE hInstance,                        HINSTANCE hPrevInstance,                        LPSTR lpCmdLine,                        int nCmdShow)     {         WNDCLASSEX wcex;         HWND hwnd;         HDC hDC;         HGLRC hRC;         MSG msg;         BOOL bQuit = FALSE;         float theta = 0.0f;              /* register window class */         wcex.cbSize = sizeof(WNDCLASSEX);         wcex.style = CS_OWNDC;         wcex.lpfnWndProc = WindowProc;         wcex.cbClsExtra = 0;         wcex.cbWndExtra = 0;         wcex.hInstance = hInstance;         wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);         wcex.hCursor = LoadCursor(NULL, IDC_ARROW);         wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);         wcex.lpszMenuName = NULL;         wcex.lpszClassName = "GLSample";         wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);;                   if (!RegisterClassEx(&wcex))             return 0;              /* create main window */         hwnd = CreateWindowEx(0,                               "GLSample",                               "OpenGL Sample",                               WS_OVERLAPPEDWINDOW,                               CW_USEDEFAULT,                               CW_USEDEFAULT,                               256,                               256,                               NULL,                               NULL,                               hInstance,                               NULL);              ShowWindow(hwnd, nCmdShow);              /* enable OpenGL for the window */         EnableOpenGL(hwnd, &hDC, &hRC);              /* program main loop */         while (!bQuit)         {             /* check for messages */             if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))             {                 /* handle or dispatch messages */                 if (msg.message == WM_QUIT)                 {                     bQuit = TRUE;                 }                 else                 {                     TranslateMessage(&msg);                     DispatchMessage(&msg);                 }             }             else             {                 /* OpenGL animation code goes here */                      glClearColor(0.0f, 0.0f, 0.0f, 0.0f);                 glClear(GL_COLOR_BUFFER_BIT);                      glPushMatrix();                 glRotatef(theta, 0.0f, 0.0f, 1.0f);                      glBegin(GL_TRIANGLES);                          glColor3f(1.0f, 0.0f, 0.0f);   glVertex2f(0.0f,   1.0f);                     glColor3f(0.0f, 1.0f, 0.0f);   glVertex2f(0.87f,  -0.5f);                     glColor3f(0.0f, 0.0f, 1.0f);   glVertex2f(-0.87f, -0.5f);                      glEnd();                      glPopMatrix();                      SwapBuffers(hDC);                      theta += 1.0f;                 Sleep (1);             }         }              /* shutdown OpenGL */         DisableOpenGL(hwnd, hDC, hRC);              /* destroy the window explicitly */         DestroyWindow(hwnd);              return msg.wParam;     }          LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)     {         switch (uMsg)         {             case WM_CLOSE:                 PostQuitMessage(0);             break;                  case WM_DESTROY:                 return 0;                  case WM_KEYDOWN:             {                 switch (wParam)                 {                     case VK_ESCAPE:                         PostQuitMessage(0);                     break;                 }             }             break;                  default:                 return DefWindowProc(hwnd, uMsg, wParam, lParam);         }              return 0;     }          void EnableOpenGL(HWND hwnd, HDC* hDC, HGLRC* hRC)     {         PIXELFORMATDESCRIPTOR pfd;              int iFormat;              /* get the device context (DC) */         *hDC = GetDC(hwnd);              /* set the pixel format for the DC */         ZeroMemory(&pfd, sizeof(pfd));              pfd.nSize = sizeof(pfd);         pfd.nVersion = 1;         pfd.dwFlags = PFD_DRAW_TO_WINDOW |                       PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;         pfd.iPixelType = PFD_TYPE_RGBA;         pfd.cColorBits = 24;         pfd.cDepthBits = 16;         pfd.iLayerType = PFD_MAIN_PLANE;              iFormat = ChoosePixelFormat(*hDC, &pfd);              SetPixelFormat(*hDC, iFormat, &pfd);              /* create and enable the render context (RC) */         *hRC = wglCreateContext(*hDC);              wglMakeCurrent(*hDC, *hRC);     }          void DisableOpenGL (HWND hwnd, HDC hDC, HGLRC hRC)     {         wglMakeCurrent(NULL, NULL);         wglDeleteContext(hRC);         ReleaseDC(hwnd, hDC);     }


Case Class naming convention

In my recent adventures in **Scala** , I've found **case classes** to be a really nice alternative to enums when I need to include a bit of logic or several values with them. I often find myself writing structures that look like this, however:               object Foo{       case class Foo(name: String, value: Int, other: Double)            val BAR = Foo("bar", 1, 1.0)       val BAZ = Foo("baz", 2, 1.5)       val QUUX = Foo("quux", 3, 1.75)     }      I'm primarily worried here about the naming of the object and the case class. Since they're the same thing, I end up with `Foo.Foo` to get to the inner class. Would it be wise to name the case class something along the lines of `FooCase` instead? I'm not sure if the potential ambiguity might mess with the type system if I have to do anything with subtypes or inheritance.


What are solutions and tradeoffs to maintain search result consistency in a web application

Consider a web application with a custom search function that must display the results in a paged manner (twenty per page with up to hundreds of thousands of total results) and the ability to drill down to individual results that maintain next/previous links to navigate through the results. Re-executing the search on each page request to get the appropriate results for that page of data can be too expensive (up to 15s per search). Also, since the underlying data can change frequently (e.g. addition of new results), re- executing could cause the next/previous functionality to result in inconsistent behavior (e.g. the same results reappearing on a later page after having been viewed on an earlier page). What options exist to ensure the search results can be viewed across multiple pages in a consistent manner, and what tradeoffs does each option have in terms of network, CPU, memory, and storage requirements? EDIT: I thought caching the query search results was an obvious necessity. The question is really asking about where to cache the result set and what tradeoffs might exist to each. For example, storing the ids of the entities in the result set on the client, or storing the IDs of the entities themselves in the users session on the web server, or in a temporary table in the database. I'm not looking specifically for a single solution as different scenarios may result in different approaches (and such a question would be more suited for stackoverflow.com rather than here), but more of a design comparison between the possible approaches.


Contract / Freelance Programming, The initial communication process / sending documents to them (terms, etc)

I've been searching around for info on contract / freelance programming as far as steps to take in the initial communication with a client (someone who has contacted me regarding a project). I am wondering if anyone has links to good resources as far as what I should send them (should I send them a document outlining "my process", etc?). Often the initial requirements that they send are vague and I want to immediately "take charge" of the process and starting asking them questions, talking about price, etc but I don't want to be too overbearing so I'm just curious if there is much out there written about this, my google searches aren't turning up much that is good about this sort of thing.


What approach to use to query multiple XML files?

I'll be receiving tens of thousands of XML files, which will continue to grow with new files over time. I need to be able to query these files as a whole (like SQL querying all the records in a database). What technologies and/or approaches should I be looking at for this problem? I feel like I should be looking into XQuery. I'm not that familiar with it, though. **UPDATE 1:** Example queries I might run:   * Return all the product code, product name, product description from all XML files in /folder 1/ where the supplier id = x and store id = y   * Return all the product code and product price from all XML files in /folder 2/ where the supplier id = x and store id = y   * Maybe join the results of the two queries above, joining on product code   * As there may be multiple results per product code for the two queries above, only get the most recent values based on some tag / attribute in the XML **UPDATE 2:** It seems like this article suggests that XQuery can be used: http://www.ibm.com/developerworks/xml/library/x-xquerymaven/index.html?ca=. As I am implementing a LAMP solution, I think there might be XQuery libraries available to PHP. Does this mean that I don't need an XML database to query loads of XML files?


Safe project development - free repositories

Some time ago we started a private hobby project. We made a project on javaforge.com, created an svn repository and started developing our app. Right now we are really far with our project, but somehow we never worried if our project is really safe on such free development tool like javaforge ? I mean, what if our project would earn some money and the source code become valuable ? Could it be stolen or could somebody take it over ? We want to be sure that we are not wasting our time and want to be really sure about our project safety. Is it possible to safely develop a project in such free repository ? We would like also to start using redmine, so if you know any safe place for moving our project, please take this under consideration. Thanks a lot.


Is it a really required skill to program without API documentation?

I barely passed my Java programming exam today. I had to answer some general questions about threading which I did well and to write a little threaded program which was worse. I had to connect my laptop to the projector screen and write the program right away. My first attempt was to use anonymous classes but I forgot the exact syntax. Maybe because of some excitement or maybe because last two weeks I was coding mostly in php. Then I asked is it allowed to use the API documentation. The answer was "NO". So I decided to go another way around and I implemented Runnable. The program was doing what was requested at the end. Of course the examiners noticed my first fail and that affected my score greatly. I was amazed that it was not allowed to use the API documentation. So, my question is: Is it really important to be able to code flawlessly without API documentation? Should I develop this skill? Is it really important in the real world and in the work environment? While on programming courses I focused on learning patterns, developing skills to write good design applications, skills to use API and find the necessary information fast. I was not trying to learn how to program without API documentation. Is it must-have during job interviews (coding without API documentation)?


How to catch DllNotFoundException in C#?

this question in my opinion straightforward. How can I catch an DllNotFoundException in C# as it is just an attribute to some methods use like this:               [DllImport("NativeLib.dll")]         private static extern void print_line(string str);      When are these functions being invoked ? As I instance the class containing the methods ( sounds odd to me as it's being "static" )? Or as I want to use the methods?


Building simulation architectures : Which one to choose?

I am writing a simulation which unites discrete event and continuous system simulation. For example, you can use State Charts, System Dynamics and Queues side by side. Theese will then reduced to DEVS, a mathematically defined and executable modelling formalism. Now I became stuck on how to organize the systems architecture. I'd like to use some kind of MVC pattern, so I thought lets make a state machine model, controller and state diagram, lets make a system dynamics model, controller and a stock and flow visualization, and so on. But these are also expressible via the DEVS model but it would be a bit complicated doing the translation to DEVS on the fly inside the controller ... So, should i have multiple models and representations which are then reduced to DEVS (base model) OR should I work directly with the DEVS base, so that e.g. the state machine is visualized as a state diagram, but internally it is automatically converted to the base model. Which architecture would you recommend?


Multiple Same Object Instantiation

What exactly happens in Java when you instantiate the same object multiple times? For example:               Test test = new Test();      then later on I will call it again, `Test test = new Test();` again or inside a loop. Will the previous instantiation be disposed?


Java - Why do we call an array a "vector"?

I am reading a book on Java Programming, and want to confirm I understand the definition of the word "vector". Wikipedia says vector is "A one-dimensional array", source http://en.wikipedia.org/wiki/Vector. Wouldnt it be simpler to call the array simply an array? Is there any reason we need to use such fancy language as "vector"? Is there a difference between an array and a vector?    ![enter image description here](http://i.stack.imgur.com/daFEx.png) Source: Cracking the Coding Interview, 4th Edition, by Gayle McDowell, page 47. FAQ   Q - Why didnt you post this on english.stackexchange.com?   A - Because I think only computer science oriented people will have a good answer.


Examples of UNIX Domain Socket Usage

Can anyone give an example of instances in which the AF_UNIX i.e unix domain sockets are used for process communication in a unix-based system


C++11 Header-only Library: in-class body vs. out-class body code?

## BACKGROUND:optional **Since 2002** I've been slowly building my own **Windows Native C++ library**. And let's just say that I have jumped **150KLOC** _(reusable code)_ having everything I need and the kitchen sink in it _(from most of the Windows API objectualized to a decent IMAP4 client implementation and the WordPress XMLRPC client for mass publishing... I do Affiliate Marketing and SEO Tools)_. It's not yet `.NET` but it ain't that far :) The only **3rd party libraries** used in it are `ZLib`, `MySQL` and `SQLite`. Everything else is built from scratch using the `STL` and/or `Windows API`. _(I still have a PDF writer/reader to implement, IOCP all network things, and there's always room for more work...)_ **For the past 1.5 years I've been in a sustained effort of updating it for C++11.** Move semantics where due, _(explicit)_ bool operators, chained constructs and much more of what _(MSVC's modest)_ C++11 brought us. Plus CRTP for chained parent/child calls, minimal use of virtuals, strict const- correctness. **And succeeded.** **Recently I've been really considering publishing it.** It's a huge amount of work that I've only done for my own benefit and I assume there's still `Windows C++` devs out there that could use such a thing. And to do that, went on to read **C++ code practices and API/Library design guidelines**. It was great! I nailed 80-85% of best coding practices myself. With a few things I'll address soon and **one major question**. ## QUESTION **Currently the entire library is quite-templated and header only.** That means all code is in the body of the classes. It's not very easy to manage but it's OK. I collapse code, use `#pragma region`s and nicely structure things. **BUT I'm VERY tempted, after reading several C++ library coding guidelines, to break it into`.hpp` \+ `.inl` files.** Experimentally done so for a few classes and it does increase readability and makes it easier for others to deal with _(even if it's a bit harder to write)_. I know where everything _(line of code, functionality)_ is at any given time. But other users might want to a quick overview of a classes declaration... and the definition ONLY if/when necessary _(debugging)_.   1. **What are the accepted and/or preferred practices regarding splitting declarations from definitions.** Would you rather have header only classes with in-body code or code separated from the function declaration?   2. **What are the current practices of other libraries?** I've always written everything myself. Not that up to speed with how others do it. Except the 3 libraries mentioned above, I've yet to use other 3rd party code. > **This is an important question for me because it's a one way road.** I > can't refactor it the other way later on so **any feedback matters and is > appreciated**... _Thanks_.


Are there any good reasons to use, learn, or recommend XSLT?

I am a developer for the last 8 years. We used XSLT primarily to transform XML into HTML. We also used it for XML to XML transformation. But we have replacement for everything now. HTML can be comfortably created through programming languages such as ASP.Net. XML can be read and manupulated in any standard highlevel languages. As programming in XSLT is a little complex, any one would prefer working on latest programming languages. Now my question: Will XSLT be a significant choice in future, not considering the fact of maintaining already developed XSLT? Can I recommend new programmers to study XSLT?


How would one go about building pluggable software?

If you have an application of some sort and you want your users to be able to write plugins for it, how should the application be designed? What do you have to take into account, what design patterns are for this etc?


Who usually does the use case analysis in the team?

I've just started my first IT job in a team with two developers (junior and senior), a project leader and an architect. My role is not yet completely defined and I said I'd be ok with both programming or testing. For now they put me on use case analysis since the PL says that it would leverage my analytical skills (I'm a science phd). Now the question is who's usually responsible for use case analysis? How usual is it to put a newbie on it? The hidden fear I have is: are they trying to keep me away from programming (after two weeks I still haven't SEEN a line of code...)?


Dynamic typing across the whole technology stack - where to enforce data validity?

Over the past year or two, I've been playing with newer technologies in my side projects. As a web developer, I've gone from the following (and still the following, at work): ## The 'classic' technology stack   1. Web browser POSTs forms to...   2. a C#-coded web application server-side, communicating to...   3. external services via XML, then ultimately...   4. writing the application state to a SQL database. To using a very different arrangement: ## The fully-dynamic technology stack   1. Web browser submitting XmlHttpRequests to...   2. a JavaScript-coded Node.js server-side, communicating to...   3. other external services via RESTful services in JSON, ultimately...   4. writing the application state to a no-SQL database It's gotten to the point where my whole stack has absolutely **no enforcement of type or schema, anywhere**. Now, this has been just fine before, when consuming others' web services. It might have even been fine up until the SQL databases were ditched (along with their DB schemas). But now I'm stuck at: ## Where do I _declaratively_ define what is the valid structure of my business-domain data? I want to enforce data validity before making any of my projects publically available - after all, what's to stop someone from just submitting invalid data to my services, and using it all as just a hacky free database provider? At some point, it has to be enforced that "this web service will only accept a collection of at least one X. X must contain A, B, and optionally C". The first solution I thought of was to do validation inside my node.js, through a big block of imperative code/if-elses/etc. This felt wrong. I have been using CouchDB, and for a while I thought that it might be best to put that validation code in the `_update` handlers. At least we're performing validation as part of persistence, but it's still an ugly imperative block. Next, I looked into JSON schema languages. There is no standard as far as I can see, and I wasn't confident in the multiple solutions offered. I could roll my own, but then I'd only be expanding the body of non-standard JSON schema languages. XML? I could put the **X** back into AJAX, and have them all schema-validated on the server side. That doesn't seem to follow the trends in software development, however. Neither would using an XML data store instead of a JSON CouchDB/BSON MongoDB persistence layer. So, I'm stuck. Ideas? **TL;DR** Where do I declaratively define the valid structure of my business- domain data when I am using no static Object Oriented language, and no schema- bound SQL database, in my technology stack? Is it possible that there must be some static typing (or DB schema, or validated XML) _somewhere_ for a technology stack to make any sense? If so, where?


What is a cross-platform way to expose an Array[][] over a webservice? Any JSON nuances to be aware of?

I need to expose an Array[][] to many different clients (iPhone, Android, PC, Unix, etc), and need to make it available over HTTP/s This brings me to JSON, and makes me wonder how do all the other *endian machines work with JSON and will I need to worry about how the array will be reconstructed on other platforms. Initially this will be an array of UTF8 strings, but I want to support other types, for example, Array[0][] will be a image, while Array[1][] will be a audio file. ...etc. If JSON is the right way to send Array[][] data across HTTP, what "gotchas" should I be concerned about?


How do I cache data that rarely changes?

In my ASP.NET application there is some data that doesn't change often and so there is no point in querying the database to re-check it every time. In my current situation I am checking user credentials on every request to see if they have access for what they are attempting to do (i.e. view a particular page). The security information is stored in the database and I'm noticing a performance hit on every page load. The load time goes from 20ms to 200ms because of the database queries. It seems to me that I should cache the security-related information so that pages are rendered faster (the data can be refreshed when the application restarts), but I don't know how to go about this. I've searched around for caching methods but no solutions I've seen are about what I'm trying to do. One way is to store the security information as read-only in a static class or persistent repository that is created and loaded on application startup. Another way is to use the Tracing and Caching Provider Wrappers for Entity Framework, but according to an answer on StackOVerflow called How to make Entity Framework cache some objects user Alex James says > sometimes this approach is overkill Is there any disadvantage to storing the data in a few read-only variables (memory concerns?) and any clear advantage to using the caching provider?


Would it be ethical to create an open source alternative to the software you've been hired to create?

Say you were hired to create education software that will be sold to students of a particular academic institution. You are the only developer working on this project and have written all of the code. An open source alternative to the project has the potential of benefiting underprivileged students from around the world. In short, a free alternative would contribute to the greater good of humanity. Would it be "OK" to create an open source alternative to the software that you are being paid to develop? P.S. The software will only be used by the students of the institution. There are no plans to distribute it commercially. The application does not make use of other people's intellectual property.


Pulling in changes from a forked repo without a request on GitHub?

I'm new to the social coding community and don't know how to proceed properly in this situation: I've created a GitHub Repository a couple weeks ago. Someone forked the project and has made some small changes that have been on my to-do. I'm thrilled someone forked my project and took the time to add to it. I'd like to pull the changes into my own code, but have a couple of concerns. 1) **I don't know how to pull in the changes via git from a forked repo.** My understanding is that there is an easy way to merge the changes via a pull request, but it appears as though the forker has to issue that request? 2) **Is it acceptable to pull in changes without a pull request?** This relates to the first one. I'd put the code aside for a couple of weeks and come back to find that what I was going to work on next was done by someone else, and don't want to just copy their code without giving them credit in some way. Shouldn't there be a to pull the changes in even if they don't explicitly ask you to? What's the etiquette here I may be over thinking this, but thanks for your input in advance. I'm pretty new to the hacker community, but I want to do what I can to contribute!


Is the potential performance hit from LINQ worth it for improved readability?

We are considering using LINQ (to Objects) in our (commercial grade) projects where performance may be an issue. I have heard it may impact performance, but then the code is so much more readable and maintainable. Is this trade-off really worth it?


Programming your own linux distribution?

So, during the couple of days I've been thinking what it takes to make your own linux distribution. Where should I actually start? I'd like to have some very basic tips for this. I consider myself a decent programmer, mainly in c++ and objective c. And what limits there are in making a distro?


Why should large financial/insurance companies use git and/or github

I work for a large enterprise (30K employees) in the financial/insurance industry. While "IT" isn't our main focus, let's be honest, these are information driven industries and the companies with the better technological advantage seem to get ahead faster. There are many software development teams at my company. They are all over the map with version control, let alone languages/frameworks used. Some don't use any (I know), some use PVCS, some use VSS, and the most enlightened use SVN. I want to bring git to my enterprise. More specifically, I want to bring GitHub (private repositories). I know the right people to talk to about this, but let's be honest again, drastic moves like this usually get shot down in the large enterprise setting because of vague security concerns or the fact that none of our competitors are using it (and I can only cite jQuery, Ruby on Rails, Facebook, etc as references). So my question is this. What are the most compelling reasons of why a large enterprise should slowly and deliberately make the switch from PVCS/VSS/SVN to a hosted git solution like GitHub (private repo). Of course, part of my plan involves a POC for a non-essential development project.


Does F# offer anything particularly useful for database-driven web development?

My organization finally upgraded to MS Visual Studio 2010 this year. One of the big new features that Visual Studio 2010 offers is the F# programming language. I understand that F# offers a functional programming paradigm, similar to Lisp. Unlike Lisp though, F# is compiled into managed code for the .net framework. Right now, I work in database-driven web application development. Right now, I'm working with an n-tier application with SQL code on the back end and a C#.net AJAX web application on the front-end. I would like to know if F# offers anything that would be particularly useful for this type of development.


Should angularjs directive directly interact with services or is it considered an anti-pattern?

Which one is considered better:   * having a directive that interacts with services directly or   * having a directive that exposes certain hooks to which controller may bind behaviour (involving services)?


Would you still use Java in your next project, despite the whole mess in JCP

It seems that there is a whole mess around current JCP. Quite of number of highly respected guys like Doug Lea, Tim Peierls had quit JCP. Reference : Is JCP dead? and Final results of the JSR Review Ballot for JSR #336 This put Java in an unfavorable future. As a Java developer, will you still consider using Java in your next project?


Indenting labels in C

I noticed that in the Vim automatically indents labels in a rather unintuitive way (IMHO).               int main(void) {          goto end;          end:         return 0     }      Are there any style guidelines for labels? For the faint-hearted, the goto's I am using are for error handling in a controlled and structured manner.


Open source projects and MDD?

Model-driven development seems to have a lot of buzz in certain software engineering circles, but I've never encountered an open source MDD projects "in the wild". Are any open source projects using model-driven development? (I don't just mean that there's some UML documentation, but that the primary artifacts that the developers manipulate are the models, rather than the code).


Approach on Software Development Architecture

I am planning to standardize our way of creating project for our new projects. Currently we are using 3tier architecture where we have our ClassLibrary Project where it includes our Data Access Layer and Business Layer Something like:                  Solution ClassLibrary           >ClassLibrary Project :               >DAL(folder)                    > DAL Classes               >BAL(folder)                    > BAL Classes      And this Class Library dll was reference on our presentation Layer Project which are the Application(web/desktop) Something like:                    Solution WebUniversitySystem           >Libraries(folder)               > ClassLibrary.dll          >WebUniversitySystem(Project):               >Reference ClassLibrary.dll                >Pages etc...      Now i am planning to do is something like:                Solution WebUniversitySystem           >DataAccess(Project)          >BusinesLayer(Project)               >Reference DAL          >WebUniversitySystem(Project):               >Reference BAL               >Pages etc...      Is this OK? Or there is a good approach that we can follow?


How to handle "circular dependency" in dependency injection

The title says "Circular Dependency", but it is not the correct wording, because to me the design seems solid.   However, consider the following scenario, where the blue parts are given from external partner, and orange is my own implementation. Also assume there is more then one `ConcreteMain`, but I want to use a specific one. (In reality, each class has some more dependencies, but I tried to simplify it here) ![Scenario](http://i.stack.imgur.com/GplrD.png) I would like to instanciate all of this with Depency Injection (Unity), but I obviously get a `StackOverflowException` on the following code, because Runner tries to instantiate ConcreteMain, and ConcreteMain needs a Runner.               IUnityContainer ioc = new UnityContainer();     ioc.RegisterType<IMain, ConcreteMain>()        .RegisterType<IMainCallback, Runner>();     var runner = ioc.Resolve<Runner>();      How can I avouid this? Is there any way to structure this so that I can use it with DI? The scenario I'm doing now is setting everything up manually, but that puts a hard dependency on `ConcreteMain` in the class which instantiates it. This is what i'm trying to avoid (with Unity registrations in configuration). All source code below (very simplified example!);               public class Program     {         public static void Main(string[] args)         {             IUnityContainer ioc = new UnityContainer();             ioc.RegisterType<IMain, ConcreteMain>()                .RegisterType<IMainCallback, Runner>();             var runner = ioc.Resolve<Runner>();                  Console.WriteLine("invoking runner...");             runner.DoSomethingAwesome();                  Console.ReadLine();         }     }          public class Runner : IMainCallback     {         private readonly IMain mainServer;              public Runner(IMain mainServer)         {             this.mainServer = mainServer;         }              public void DoSomethingAwesome()         {             Console.WriteLine("trying to do something awesome");             mainServer.DoSomething();         }              public void SomethingIsDone(object something)         {             Console.WriteLine("hey look, something is finally done.");         }     }          public interface IMain     {         void DoSomething();     }          public interface IMainCallback     {         void SomethingIsDone(object something);     }          public abstract class AbstractMain : IMain     {         protected readonly IMainCallback callback;              protected AbstractMain(IMainCallback callback)         {             this.callback = callback;         }              public abstract void DoSomething();     }          public class ConcreteMain : AbstractMain     {         public ConcreteMain(IMainCallback callback) : base(callback){}              public override void DoSomething()         {             Console.WriteLine("starting to do something...");             var task = Task.Factory.StartNew(() =>{ Thread.Sleep(5000);/*very long running task*/ });             task.ContinueWith(t => callback.SomethingIsDone(true));         }     }


What common apporaches exist for database versioning for a feature driven development?

It's not clear how data consistency is provided for different branches. We have a large knowledgebase which is filled by the experts and delivered as updates to our clients. This data is also used for testing the product.   But if we have quite a few feature branches (being developed in parallel) and each feature requires its own slightly different db schema won't it be a hell? Definitely some way of populating all DBs from one centralized store must exist. And here comes the question? What are these methods? Now the only solution I see is to create some mapping mechanism and to save mappings in the corresponding DB, yet I believe more elegant approaches exist. **Update:** To clarify the problem.   We have one (let's call it master db). And N databases with slightly 'narrower' schemas comparing to the chema of master. I.e. master is has the richest schema: other dbs have fewer tables/columns.


Are CK Metrics still considered useful?  Is there an open source tool to help?

Chidamber & Kemerer proposed several metrics for object oriented code. Among them, depth of inheritance tree, weighted number of methods, number of member functions, number of children, and coupling between objects. Using a base of code, they tried to correlated these metrics to the defect density and maintenance effort using covariant analysis. Are these metrics actionable in projects? Perhaps they can guide refactoring. For example weighted number of methods might show which God classes needed to be broken into more cohesive classes that address a single concern. Is there approach superseded by a better method, and is there a tool that can identify problem code, particularly in moderately large project being handed off to a new developer or team?


Breadcrumbs in a modern web application, make sense?

I'm currently beginning with the development of a new web application. The whole web application is going to be bookmarkable and all the pages accesible via _GET_ requests and url parameters. Having said that, let's suppose I've got three entities in my application, `Customer`, `Team` and `City`. Each `Customer` and `Team` belong to a city and I've got a `city-detail` page which displays the detail for a concrete city. So next navigation cases are possible: _Customers -> Customer detail (id=2) -> City detail (id=3)_ _Football teams -> Team detail (id=5) -> City detail (id=3)_ _Cities -> City detail (id=3)_ There are three possible ways of ending up in a city detail view. My question is, does it make sense to implement a breadcrumb to show such a history, having it available in the browser itself? Would it be more appropiate to show a breadcrumb with the last case, no matter where we're coming from (hierarchical breadcrumb)? That's what Jakob Nielsen points out here: > Offering users a Hansel-and-Gretel-style history trail is basically useless, > because it simply duplicates functionality offered by the Back button, which > is the Web’s second-most-used feature. > > A history trail can also be confusing: users often wander in circles or go > to the wrong site sections. Having each point in a confused progression at > the top of the current page doesn’t offer much help. > > Finally, a history trail is useless for users who arrive directly at a page > deep within the site. Also, even if the history trail seems the most natural way to implement it, it requires an extra effort to keep the whole track being HTTP a stateless mean.


Is it a good idea to create shared UI library that would render natively on different platforms?

I am designing an application that has following flow:   1. User designs a form using web application ( **J2EE** backend application)   2. The form is sent to mobile device ( **Android** )   3. Mobile device User fills out the form designed in 1.   4. Results are synced with backend. One of my ideas is to create a common java UI library for creating the type of forms that I need. This library would also have a native renderers for different platforms (Web and Android would be implemented first). The whole point of it is to have a native experience on web and android side. Are there any existing solutions to meet the requirements that I have? Is it a good approach to achieve them?


Is a Metro application installation restricted through Windows Store only?

I found that Windows 8 allows packaging and deploying of Metro applications and it can be installed by clicking on a ".bat" file. How will it technically be ensured that the applications can be installed through Windows Store only? Can't the developers just host the package at a different location from where users can install it?


books/articles about project managment/guiding of other programmers

I'll soon be assigned a few other programmers to guide through the development process and will be in the role of the _git_ ("Integration Manager") and generally become a project manager. Telling the truth, I've never done anything like that. I understand that such experience comes through practice, but it wouldn't harm to read about others' experience. Perhaps you know some book or set of articles or something of that kind about the project management? I'm interested not only in how to separate tasks and control their execution, but also in the psychological part. Say, how to inspire the developers, keep a good atmosphere in the group and "reward" / "punish" when necessary, and how to do that correctly; how to point out that some solution is not good enough without offending the team member, etc, etc.


"Guiding" a Domain Expert to Retire from Programming

I've got a friend who does IT at a local non-profit where they're using a custom web application which is no longer supported by the company who built it. (out of business, support was too expensive, I'm not sure...) Development on this app started around 10+ years ago so the technologies being harnessed are pretty out of date now - classic asp using vbscript and SQL Server 2000. The application domain is in the realm of government bookkeeping - so even though the development team is long gone, there are often new requirements of this software. Enter the... The domain expert. This is an middle aged accounting whiz without much (or any?) prior development experience. He studied the pages, code and queries and learned how to ape the style of the original team which, believe me, is mediocre at best. He's very clever and very tenacious but has no experience in software beyond what he's picked up from this app. Otherwise, he's a pleasant guy to talk to and definitely knows his domain. My friend in IT, and probably his superiors in the company, want him out of the code. They view him as wasting his expertise on coding tasks he shouldn't be doing. My friend got me involved with a few small contracts which I handled without much problem - other than somewhat of a communication barrier with the domain expert. He explained the requirements very quickly, assuming prior knowledge of the domain which I do not have. This is partially his normal style, and I think maybe a bit of resentment from my involvement. So, I think he feels like the owner of the code and has entrenched himself in a development position. So... his coding technique. One of his latest endeavors was to make a page that only he could reach (theoretically - the security model for the system is wretched) where he can enter a raw SQL query, run it, and save the query to run again later. A report that I worked on had been originally implemented by him using 6 distinct queries, 3 or 4 temp tables to coordinate the data between the queries, and the final result obtained by importing the data from the final query into Access and doing a pivot and some formatting. It worked - well, some of the results were incorrect - but at what a cost! (I implemented the report in a single query with at least 1/10th the amount of code.) He edits code in notepad. He doesn't seem to know about online reference material for the languages. I recently read an article on Dr. Dobbs titled "What Makes Bad Programmers Different" \- and instantly thought of our domain expert. From the article: >   * Their code is large, messy, and bug laden. >   * They have very superficial knowledge of their ~~problem domain and~~ > their tools. >   * Their code has a lot of copy/paste and they have very little interest in > techniques that reduce it. >   * The fail to account for edge cases, while inefficiently dealing with the > general case. >   * They never have time to comment their code or break it into smaller > pieces. >   * Empirical evidence plays ~~no~~ little role in their decisions. > 5.5 out of 6. My friend is wanting me to argue the case to their management - specifically, I got this email from their manager to respond to: > ...Also, I need to talk to you about what effect there is from _Domain > Expert_ continuing to make edits to the live environment. If that is a > problem for you I need to know so I can have his access blocked. Some > examples would help. In my opinion, from a technical standpoint, it's dangerous to have him making changes without any oversight. On the other hand, I'm just doing one-off contracts at this point and don't have much desire to get involved deeply enough that I'm essentially arguing as one of the Bobs from Office Space. I'd like to help my friend out - but I feel like I'm getting in the middle of a political battle. More importantly - if I do get involved and suggest that his editing privileges be removed, it needs to be handled carefully so that doesn't feel belittled. He is beyond a doubt the foremost expert on this system. I'm hoping this is familiar territory for some other stackechangers, because I'm feeling a little bewildered. How should I respond? Should I argue that he shouldn't be allowed to touch the code? Should I phrase it as "no single developer, no matter how experienced, should be working on production code unchecked"? Should I argue to keep him involved with the code, but with a review process? Should I say "glad I could help, but uh, I'm busy now!" Other options? Thanks a bunch!


Comma as a separator vs. comma as a delimiter

In this video, the speaker says: > "Some people get confused about how commas work. They think they should be > delimiters rather than separators. Now you can think about them either way." I don't understand the difference between a delimiter and a separator (if there is one). The implication in the video is that now (that trailing commas are valid), one can think of them as delimiters, rather than separators... Btw the language in question is JavaScript. From my understanding, the comma token has two meanings:   * as an operator (rarely used)   * as a separator (in argument and parameter lists, array and object literals, etc.) I'm not sure how a comma delimiter fits into this...


avoiding hard coding of knowledge of algorithm in tests?

I have a package of code which is suppose to tell me where to allocate elements. When I add a new element it may require repositioning of existing elements to keep my 'tree' in a format that promises a log-n search. Ultimately when I hand it a current system and new elements to add I should get a list of where to add new elements, and when/where old elements were moved to. I want to test that the set returned is valid, but I'm not certain how to. I can easily test if the elements are placed in valid locations, ie locations that won't break assumptions about my 'tree', but this doesn't ensure that I did the minimal and most efficent movement of elements. However, I can't think of how to check the moves are efficent without essentially rewriting a large part of the package just to test it's results. Since I wrote the package I know some implementation specific details. I know that A will be moved to B because I know exactly what logic was used to decide the move, but this is implementation specific. There are cases where I hae multuple equally valid choices and I pick one way when I could pick another. Is it 'right' to do this sort of functional testing by utilizing my understanding of the algorithm to specify specifially what should have moved where? if not how else would I write the test to have any idea that i'm not making the most inefficent, but valid, moves possible?


Compiling vs using pre-built binaries performance?

Will performance be better (quicker) if I manually compile the source for a software component for the actual machine that it will be used on, compared to if the source was compiled on another platform perhaps for many different architectures? I got some good results compiling source that I downloaded and I wonder whether this was due to compiling it instead of downloading a pre- compiled binary which is often the case with software updates.


Branching and versioning strategy for shared libraries

These posts seem related, but my brain is starting to melt, trying to think this through :P My employer has just started using source control, primarily because before they hired more developers, the "repository" was the hard drive of the lone dev, who works mainly from home. All of the .NET code he'd written was checked in _en masse_ , and there is a lot of duplicated (read: copy-pasted) functionality. Right now, our SCM system is glorified backup. I'd like to pull some of the duplicated code into shared libraries. I'm leaving the original repo alone so that we don't break anything—we can move and/or refactor existing code as and when needed. So I've set up a repo just for new code, including libraries. My problem revolves around versioning the libraries without miring us in excessive process: having acknowledged that we need a more coherent approach, with more devs all writing very similar code, management and the other devs are open to reorganising things, but it probably won't go down well if the solution starts to affect productivity. The ideal solution in my obsessive mind is to build the libraries separately, with each dependent project built against deliberately chosen, compatible versions of them. That way, we know exactly which clients have which versions of which libraries, can more reliably reproduce bugs, maintain independent release branches for products and libraries, and not break each other's projects when changing shared code. This makes updating the libraries cumbersome though, particularly for the dev who works from home. I expect the libraries to change quickly, at least initially as we (finally) pull the common bits together. It's quite possible that I'm completely overthinking this and we'd be fine just building everything against the most recent library commits, but I'd like to at least be _prepared_ for the day we decide that some components have to be independently versioned and distributed. The fact that some of the libraries will have to be installed in the GAC makes versioning particularly important. So my question is: what am I missing? I feel like I've fixated on one solution and am now trying to find variations on it that will make changes smoother. What kinds of strategies have you used to solve this kind of problem before? I realise this question is all over the place; I'll do my best to clean up and clarify any points of uncertainty. And as much as I'd love to use Mercurial, we've already spent money on a centralised commercial SCM (Vault) and switching isn't an option. Besides, I think the issue here goes deeper than choice of version control tool.


Keeping remote files synced with local files?

When developing web applications, how does one keep local files and remote files synced together? There is the obvious way, whenever you edit a file on your local machine, just upload that file to the remote machine. Is there a more efficient way? I ask because I have been using subversion control, and it is so easy to keep files synced on a remote server. All I have to do is "commit" and it will find the files which need to be replaced.


To maximize chances of functional programming employment

Given that the future of programming is functional, at some point in the nearish future I want to be paid to code in a functional language, preferably Haskell. Assuming I have a firm grasp of the language, plus all the basic programmer attributes (good communication skills/sense of humour/hygiene etc), what should I concentrate on learning to maximize my chances? Are there any particularly sought after libraries I should know? Alternatively, would another language be a better bet, say F#? (I'm not too fussed about the kind of programming work, so long as it's reasonably interesting and reasonably well paid, and with nice people)


Database model for keeping track of likes/shares/comments on blog posts over time

My goal is to keep track of the popular posts on different blog sites based on social network activity at any given time. The goal is not to simply get the most popular now, but instead find posts that are popular compared to other posts on the same blog. For example, I follow a tech blog, a sports blog, and a gossip blog. The tech blog gets waaay more readership than the other two blogs, so in raw numbers every post on the tech blog will always out number views on the other two. So lets say the average tech blog post gets 500 facebook likes and the other two get an average of 50 likes per post. Then when there is a sports blog post that has 200 fb likes and a gossip blog post with 300 while the tech blog posts today have 500 likes I want to highlight the sports and gossip blog posts (more likes than average vs tech blog with more # of likes but just average for the blog) The approach I am thinking of taking is to make an entry in a database for each blog post. Every x minutes (say every 15 minutes) I will check how many likes/shares/comments an entry has received on all the social networks (facebook, twitter, google+, linkeIn). So over time there will be a history of likes for each blog post, i.e                  post 1234                   after 15 min: 10 fb likes, 4 tweets, 6 g+             after 30 min: 15 fb likes, 15 tweets, 10 g+             ...             ...             after 48 hours: 200 fb likes, 25 tweets, 15 g+      By keeping a history like this for each blog post I can know the average number of likes/shares/tweets at any give time interval. So for example the average number of fb likes for all blog posts 48hrs after posting is 50, and a particular post has 200 I can mark that as a popular post and feature/highlight it. A consideration in the design is to be able to easily query the values (likes/shares) for a specific time-frame, i.e. fb likes after 30min or tweets after 24 hrs in-order to compute averages with which to compare against (or should averages be stored in it's own table?) If this approach is flawed or could use improvement please let me know, but it is not my main question. My main question is what should a database scheme for storing this info look like? Assuming that the above approach is taken I am trying to figure out what a database schema for storing the likes over time would look like. I am brand new to databases, in doing some basic reading I see that it is advisable to make a 3NF database. I have come up with the following possible schema. Schema 1               DB Popular Posts            Table: Post         post_id ( primary key(pk) )         url         title             Table: Social Activity         activity_id (pk)         url (fk)         type (i.e. facebook,twitter,g+)         value         timestamp      This was my initial instinct (base on my very limited db knowledge). As far as I under stand this schema would be 3NF? I searched for designs of similar database model, and found this question on stackoverflow, http://stackoverflow.com/questions/11216080/data-structure-for-storing-height- and-weight-etc-over-time-for-multiple-users . The scenario in that question is similar (recording weight/height of users overtime). Taking the accepted answer for that question and applying it to my model results in something like: Schema 2 (same as above, but break down the social activity into 2 tables)               DB Popular Posts            Table: Post         post_id (pk)         url         title             Table: Social Measurement         measurement_id (pk)         post_id (fk)         timestamp            Table: Social stat         stat_id (pk)         measurement_id (fk)         type (i.e. facebook,twitter,g+)         value      The advantage I see in schema 2 is that I will likely want to access all the values for a given time, i.e. when making a measurement at 30min after a post is published I will simultaneous check number of fb likes, fb shares, fb comments, tweets, g+, linkedIn. So with this schema it may be easier get get all stats for a measurement_id corresponding to a certain time, i.e. all social stats for post 1234 at time x. Another thought I had is since it doesn't make sense to compare number of fb likes with number of tweets or g+ shares, maybe it makes sense to separate each social measurement into it's own table? Schema 3               DB Popular Posts            Table: Post         post_id (pk)         url         title             Table: fb_likes         fb_like_id (pk)         post_id (fk)         timestamp         value            Table: fb_shares         fb_shares_id (pk)         post_id (fk)         timestamp         value            Table: tweets         tweets__id (pk)         post_id (fk)         timestamp         value            Table: google_plus         google_plus_id (pk)         post_id (fk)         timestamp         value      As you can see I am generally lost/unsure of what approach to take. I'm sure this typical type of database problem (storing measurements overtime, i.e temperature statistic) that must have a common solution. Is there a design pattern/model for this, does it have a name? I tried searching for "database periodic data collection" or "database measurements over time" but didn't find anything specific. What would be an appropriate model to solve the needs of this problem?


How to create own programming language based on JVM?

I am curious about how to create a programming language based on JVM so I have tried to get some info online, but the information I got are quite fragmented. What I found are mostly information related to single technologies like ASM, Eclipse JDT, JFlex, etc, but what I would like to know are the main steps that need to be implemented and suggested technologies for these steps. Any idea? Well this question sounds quite broad but I started to think that is not like that. I kept looking up information online and you can get (relative easily) a basic customized language just using ANTLR (or alternative like JavaCC) used by Groovy mixing it with ASM (alternative BCEL or same Javac compiler). The first helps you to build the necessary grammar/parsing/AST and the second to generate the final bytecode once you got a successful parsing. BTW from the same author of ANTLR I found this book that more and less is what I was looking for: http://pragprog.com/book/tpdsl/language-implementation-patterns


Who are the 1st and 2nd parties?

So, this is pure curiosity. I've heard the term 3rd party, as in, "3rd party library" for quite a while. I wonder why we say 3rd and not 2nd (or 4th)? Who are the first and second parties and where did the term come from?


Strategies for using a code metric evaluation tool

Should code quality metric evaluation tools like Sonar be integrated with IDE for running local analysis or should they be a part of the build process (like integrated with maven) for continuous inspection or should it be a combination of both? How can we leverage the power of such tools to the maximum extent possible?


What are the origins of the Public/Private function declarations?

## The Question What are the origins of the Public/Private function paradigm? ## Background A question came up in chat about Header files in C, and their usage being mainly to help the compiler, _not_ the programmer. It's my understanding though, that this is the first usage of the concept of "Private" functions, or functions which aren't prototyped in the header file. Had C not used header files to declare functions, would we still have the current concept of Public and Private functions as seen in C# or Java? Or was this concept initially developed elsewhere and simply implemented in the C Header/Source scheme


Mac Developer Library Download

I'm not sure which SE site this belonged on, so I figured I'd try this one. Whenever I browser the Mac Developer Library at developer.apple.com, on the top right of the window, there's a link for a PDF version. Has anyone ever downloaded them all and combined them into one file? I want to download the Mac Developer Library for my Kindle, and I figure there's no .mobi versions, so I'm trying to look for a PDF version. Thanks in advance and sorry if its not the correct site.


How to deal with over-complication?

I often catch myself doing code unnecessarily complicated (sad but true). Is there any set of rules, discipline, etc to help avoid that? (excluding the KISS principle, because I know it but often forget when it comes to the real code :)


Voting System like Stack Exchange

I am trying to create a voting system like Stack Exchange. Should I create a table and insert values like following and then sum up the "vote" or there are some better ways to do this? Table name: vote               id  userid   article_id  vote      1    1001      12       1      2    1002      12      -1      3    1003      12       1      4    1002      10      -1       Table name: articles                article_id     article_title   article_content  article_author        12              something       something       something             10              something       something       something            From the example above the total vote for the article `12` is `1+(-1)+1 = 1`


Wildcard user in select statement on indexed varcharcolumn

This question is based on some testing I've done recently in order to better understand SQL indexing system. **Table with 500k entries, InnoDB engine** This is a simple select query on a `varchar` field. The `name` column is **not** indexed. ![enter image description here](http://i.stack.imgur.com/0IhSU.jpg) After indexing these are the results: ![enter image description here](http://i.stack.imgur.com/LjlvL.jpg) All good until this point. When I'm trying to place a wildcard at the beginning of the search key, even though the column is indexed, the result time is the one from the non-index case: ![enter image description here](http://i.stack.imgur.com/lEMxk.jpg) I'm wondering why is this happening? Is it because the index cannot be used any more? Is this solvable in any way? can I achieve a better search time even though I'm using `%` both at the beginning and at the end of the search string? Thank you!


how to nicely use constant std::string in c++

In my current code project, there is an awful lot of constant strings I use to print out error messages. Hardcoding such strings is generally considered to be bad practice. Now I'm searching for a "clean way" to include these strings in my program. Therefore I've written a "constants.h" and "constants.cpp" which looks something like               #ifndef CONSTANTS_H_     #define CONSTANTS_H_          extern std::string error_message_1;          #endif      and the constants.cpp:               #include "constants.h"          std::string error_message_1 = "this is just a sample, not my actual naming convention. move on the the question ;-)"      So you might see the problem I have with this: due to a lot of error messages, the variable name itself is fairly long. The error message is even longer, so it crashes the standard 80 characters in one line of code. Obviously I want my code nice and clean. I don't like going far beyond the 80 charactes per line of code. I don't like somthing like the following either:               std::string error_message_1 = "this is just a sample about how to"                                   " have one string across many lines"                                   " in the source code. this is not "                                   "very pretty too..";     std::string msg = "and suddenly there's one line which is good..";     std::string error_message_with_longer_name = "and it's even "                                                  "uglier with not "                                                  "equally long "                                                  "variable names";      Storing the strings in an external file which one would read in at the start of the program does not seem to be optimal too since the compiler cannot warn about missing strings. Basically this would be a mess to maintain. So what do you do about it? Is there such a nice thing as "Resources", which I know of Android (or is it Java in general?) development? Note: Please do NOT tell me that my naming convention is bad. The above is just an example. It's not what it looks like ;-)


How to spend less time on debugging?

Following the Pareto rule, a programmer spends only 20% of his time for really useful things. I spend 80% of my time debugging, fixing small things to get everything working. Is there a way to spend less time debugging?


Does Microsoft have a free version of Visual Studio?

Not a trial, but a truly free version that they offer users to download.... I was wondering in case I somehow missed the option on their website. Any version of Visual Studio will do. If not, are there any open-source alternatives (that have similar functionality, or possibly degraded equivalent) of Visual Studio? I am running on Windows 7 if that makes any difference...


Ideas to maximize learning in a gap year taken for learning programming?

I am a high school student due to graduate in one month. After which I want to take a gap year to give myself completely to computer programming. I would appreciate your ideas for things to do in this one year, so as to gain maximum from this gap year.


What are the development procedures on large web applications?

I am interested in learning of the different procedures and environments it takes to maintain a large application. For example, in my case I use a CentOS local server, where I develop my applications and I use a version control system on some applications, then I upload it to my host-gator account and launch it live. It is a very simple procedure and at the moment that is the only one I know. I have only worked as a freelancer, so I would be interested in the procedures and environments of large tech companies. What are the general do's and don'ts of development for large app? Best practices?


Is there a software methodology newer than Agile?

Is there a software development process out there newer than agile? I mean, waterfall, then agile, then what?


What to do when a client asks for something unreasonable (from my point of view)

I'm a freelance programmer and recently I finished a website, it all works fine but there was one user that complained to my client that he couldn't log in. This problem was clearly a cookie-restriction/old browser one (I couldn't create the problem myself and hunderds of users are working with the website just fine) Now my client said: I've paid you to make something and somebody complains; so you didn't do your work correctly. What can I do in this situation and how do you guys handle this?


How much attention should be paid to patents when developing software?

Let's say I want to develop an image editing program similar to Photoshop. Is it likely that certain interface patterns and approaches are patented and I can get sued if I use them in my program as well? Do I need to take active care to avoid doing things the same way as competing software? How will I manage to make features still seem familiar to people switching from existing programs? And how much of a difference does it make if it's non profit?


Responsive Web Design vs. User-Agent Sniffing

The CSS3 `media` query feature has led to many interesting possibilities in terms of developing websites which adjust to many different screen sizes and devices. However, in practice, I'm starting to get the sense that the CSS3 `media` query feature, and the whole "Responsive Web Design" movement, may not live up to its promise. The problem I see is that, at the end of the day, web developers care mostly about whether their users are viewing content via a Desktop, Tablet, or Mobile device. But CSS3 only provides a means to detect _screen resolution_. In theory, detecting screen resolution seems like a great way to adjust for various different devices. But in practice... Suppose we have a simple Javascript function that just outputs the screen width:               function foo()     {        alert(screen.width);     }      On my Blackberry Touch, this outputs:               768      On my Samsung Galaxy, this outputs:               800      So...um, at this point, the resolution of mainstream smart phones is getting pretty close to Desktop-level resolutions. The ability to detect whether a user is viewing your website via a smartphone, tablet, or desktop, seems to be increasingly difficult if all you're going by is screen resolution. This makes me call into question the entire wisdom behind the whole CSS3 "Responsive Web Design" movement based on media queries. It almost seems like the `media` query feature is better suited towards adapting to a resizing browser window on a Desktop screen, rather than various mobile devices. Another possible technique for detecting mobile or tablet devices is to use feature detection, by checking if the `ontouchstart` event is supported. But even this is becoming increasing unreliable as many Desktop screens start to support touch. **Question:** So... as a web developer, if I can't rely on RWD or feature detection, is **user-agent sniffing** (as notoriously unreliable as always) really the best option to detect mobile devices?


How to manage automated emails sent from a web application

I am designing a web application and I am wondering how to design the architecture to manage sending automated emails. Currently I have this feature build into my web app and the emails are sent based on user input / interactions (like creating a new user). The problem is that connecting directly to a mail server takes a couple of seconds. Scaling my application up, this will be a significant bottle neck in the future. What is the best way to manage sending a large amount of automated emails within my system architecture? There won't be a huge amount of emails sent (2000 a day max). Emails don't need to be send immediately, up to 10 mins lag is fine. Update: Message queuing has been given as an answer, but how would this be designed? Would this be handled in the app and processed during a quiet period, or do i need to create a new 'mail app' or web service to just manage the queue?


.Net application on Android OS

I am Database Administrator, but now I need to know something about android applications. I need to run an existing .Net application in Android Operating System, while surfing on the internet I came to know that, I can use MonoDroid to build and run my application on Androids Operating System. I am new to this Android and MonoDroid applications, so **My questions:**   * Is it possible to run an existing .Net application on Android without modification?   * If not, is there a known set of changes necessary to make a .NET application run on Android? Thank you.


How to bootstrap managerial experience?

Most engineering manager positions require X years of managerial experience in the job description. That means as an individual contributor I can never qualify. But this experience has to come from somewhere. How can I bootstrap the managerial experience? Is internal promotion to some lead position the only possible way if I don't start my own business?


"Do you have any questions for us?" In an interview

You know the prospective company fairly well but are asked "Do you have any questions for us?". To show interest, what are some of your favorite questions to reply?


What is the best way to approach reading other people's code?

I'm a junior developer and am trying to learn by reading open source code (AutoMapper). My approach would be to first understand the requirements of the software/feature. Then look for specifics on how each requirements were implemented and dive deeper into the code until I've reached the end. I would reiterate until I've covered each requirement. I understand my question does not have a "best" answer. Please give me some input on what works for you guys. Thanks!


Why is there a "new" in Go?

I'm still puzzled as why we have `new` in Go. When you want to instantiate a struct, you do               t := Thing{}      and, obviously, you can get a pointer to a new instance by doing               t := &Thing{}      But there's also this possibility :               t := new(Thing)      This last one seems a little alien to me. `&Thing{}` is as clear and concise as `new(Thing)` and it uses only constructs you often use elsewhere. It's also more extensible as you might change it to `&Thing{3}` or `&Thing{Feets:7}`. In my opinion, having a supplementary keyword1 is costly, it makes the language more complex and adds to what you must know. And it might mask to newcomers what's behind instantiating a struct. It also makes one more reserved word. So what's the reasoning behind `new` ? Is it something useful ? Should we use it ? * * * 1 : Yes, I know it's not a keyword at the grammar level, you can shadow it, but that doesn't change the fact it's, for the reasonable developer, a reserved word.


Specify that a spawned process returns to a parent

I am using yED to build an application flow-chart, and I can't figure out a 'nice' looking way of representing that a GUI's call to spawn a process loops back to the GUI process once it terminates, other than drawing another arrow to the GUI process. Is there a better way of presenting a process looping back to its parent on return/exit other than drawing another arrow back to the parent?


Do software engineers really need to know low level stuff anymore?

As high level programming languages such as C#, Java, etc. are developing, many people claim that they will be an alternative to languages such as assembly language and C/C++, which gives you access and control to computer hardware, because programmers should focus on creating the program and solve problem, not wasting time dealing with the computer to make it work. As the hardware keeps improving, the performance difference between C/C++ and Java will not be significant, and big games might be able to be programmed in a language such as Java. That's the general idea I briefly summarise after looking at this topic on the Internet. Do you think it will become real in the near future? Does that mean everything we learn about low level stuff is not practical for the software industry anymore? Does that mean, assembly language and C/C++ will become relevant to electrical engineers only, since they would be the only ones who needs to program for their electrical components? * * * Edit: And, how much learning is enough? If we learn too much low level stuffs, we would eventually become more oriented in electrical engineering or if we learn too much math, we could be learning to become mathematicians, not programmers. I just want to know if the Math stuffs I learned (I took a Math course which covers the material similar to this book (they used different text book): Discrete Mathematics and its application) is actually as useful as our programming skill set. Many math exercises can took most of us hours to do it, and if you're serious with it, you will have less time to study programming. In our gamedev forum, even Math and Physics only have one section for it compares to programming ones. Right now I have just started reading "The Art of Computer Programming". Math is only covered in about quarter of the book, but the exercise is hard for us non-mathematicians. Even such "elementary" math, did we use it as much in our career? Some people would probably tell me reading the book TACOP is a waste of time and should probably spend time on something else more practical, even though the book is all about programming (a bit more academic compare to book explain similar things). But I think the author put in great time and effort to produce it. He can even write the full set of 5 books, while we - the audience - only have the mission to read it. Why not?


Do you use both Client-side and Server-side validation techniques?

Do you use both Client-side and Server-side validation techniques side by side when validating input from a user, e.g. via a contact form? If so, is it really necessary? Are you over engineering? Regards TDG


Specifically for JS, CSS, HTML: what is the difference between optimization, compression, minification, tidying, concatenation?

When we talk about source code and the file which contains the code like CSS, HTML, JavaScript and we also talk about performance of a web site or application, what is the differences between these terms?   * Optimization   * Compression   * Minification   * Tidying   * Concatenation


Incorporating GoF design patterns in Objective-C without Abstract/Virtual classes

As someone who is becoming more comfortable working in Objective-C I would like to be able to incorporate more design patterns and OOP features in my projects but struggle to implement them as required by GoF because you cannot create an abstract class. I want to 1) avoid lots of subclassing, 2) minimize use of `respondsToSelector`, `conformsToProtocol`, etc, 3) avoid techniques like `swizzling` as much as possible, 4) maximize encapsulation, and 5) avoid long conditionals or lots of `typedef enum`. For example, in a recent project I wanted to separate `RestKit` (a library for accessing RESTful services) from my `UIViewController` subclasses. I did so by incorporating an `Adapter` between the two with a base class of `ModelController`, which could access models. I also created the `ModelControllerDelegate` protocol for my VC's to wire up. But I experienced great difficulty in creating a `ModelControllerDecorator` without the use of an abstract base class. I wanted to be able to decorate my `ModelController` with different aspects, like `PaginationDecorator`, `CompressionDecorator`, `QueryableDecorator`, and so forth. I've heard that using Objective-C++ is one way to incorporate more OOP features, but how about using standard Objective-C language features? How have you been able to incorporate GoF design patterns that use C++ style features (like `virtual` classes) in your projects?


Why maven so slow compared to automake?

I have a Maven project consists of around 100 modules. I have reason to decompose the project to so many modules, and I don't think I should merge them in order to speed up the build process. I have read a lot of projects by other people, e.g., the Maven project itself, and Apache Archiva, and Hudson project, they all consists of a lot of modules, nearly 100 maybe, more or less. The problem is, to build them all need so much time, 3 hours for the first time build (this is acceptable because a lot of artifacts to download), and 15 minutes for the second build (this is not acceptable). For automake, things are similarly, the first time you need to _configure_ the project, to prepare the magical config.h file, it's far more complex then what maven does. But it's still fast, maybe 10 seconds on my Debian box. After then, `make install` requires maybe 10 minutes for the first time build. However, when everything get prepared, the `.o` object files are generated, they don't have to be rebuild at all for the second time build. (In Maven, everything rebuild at everytime.) I'm very wondering, how guys working for Maven projects can bare this long time for each build, I'm just can't sit down calmly during each time Maven build, it took too long time, really.


What imperative programming languages do not support recursion?

To my knowledge, all modern imperative programming languages support recursion in the sense that a procedure can call itself. This was not always the case, but I cannot find any hard facts with a quick Google search. So my question is: Which languages did not support recursion right from the start and when was that support added?


Front End Application Development

I want to start a side project at the company i work for. Right now we are a 100% web based company. I have an idea for a fun project that would install an application on your computer. Anyways, i am not here to discuss the product. I am here to ask about the front end application development. I am a good C++ programmer but only algorithms (I have over 10 years in web development). I have never made a UI application before (minus the old school VB days). I would like to know my options for the front end application for windows, osx and linux. What are the popular choices these days for the UI of applications in windows, osx and linux?


How to test a website?

I found it's really hard to divide the task of developing a website to a team of people. The problem is a website should have consistent looking and be integrated in users' view. The style and page template need to be shared by all parts. Most of the website is access restricted, the access control system is dependent of all modules. Some modules need data from other modules (you can never ask user the same question again). Although these modules may run independently. The test data have to be generated by other ones. With the increase of code, the website becomes harder and harder to test. Although we are maintaining a script to automate the deployment. But if anything goes wrong, a developer cannot solve the problem by himself, for he is not familiar with others' work. What makes things worse is the configuration. Server settings are highly machine dependent. Some functions need to schedule tasks, so there are some crontab configurations. Some modules need other daemons running in the backend. Some applications require URL rewriting. To test the website, we need to configure all dependencies of all modules on all machines. Is there any suggestion about how to test a website?


The Agile process: how and what should be documented?

A while ago the company I work for had outsourced a development project to a third party. They employed agile practices in developing the solution. However when asked for documentation they would just say it was required as it was incorporated in a wiki or as part of their sprints. They did leave at the completion of the project, with all but one of the project team. The project wiki site has now been closed down once the yearly subscription was due. When they left they took most of the knowledge and understanding of what was developed with them. So I do have 2 main questions;   1. Is this normal for agile or just an excuse for not wanting to write it?   2. What are the industry norm for documentation in agile projects to record development requirements, designs, key decisions and context?


Access Control List with many roles

I normally have 2 roles in most of my websites, i.e. `Admin` and `Member` and create one folder for each Role like                /Root        /admin        /member      but now I have come up with `10 Roles` besides `Admin` and each role represents a department in a Company. And each role has only access to their `Department's tables` e.g Users with `accounts` roles have access to table related to accounts info and so on... Now I am not sure if it will be a better way to create as many folders as the number of roles. And under that folder I will have almost same templates and same Queries where templates may contain different `links` and `Queries` maybe different `Tablename` Which will lead to a maintenance nightmare. What will be the best way to handle this?


What will be enablers of cloud based integration ("Cloud Service Bus")

Both cloud computing (specifically SaaS) and SOA promote the idea of services for transforming software to a commodity. However, most SaaS providers focus mainly on providing the service to the end user, but the products aren't well suited for back-end integration. Most providers provide only an API access to their service. Some provide also integration with other _specific_ SaaS services But if one wants to aggregate data and functionality from different services which weren't planned to work together, he needs to use traditional tools to access and consolidate them - loosing many of the benefits of SaaS **A concrete example** Consider an organization that uses a SaaS solution for CRM, and another one for HR management. both of them will probably include an API (REST or WS) that allow to interact with them. However, most chances, that they won't allow you to directly synchronize user profiles between them. To do so you need to pull data from the HR system, and send it to the CRM system. this mechanism isn't currently available as a cloud service. and you will need to use "standard" integration technologies - either dedicated tools (ESB, EAI) or custom code, that will run on a server that you need to maintain. What do you think will be enablers of cloud based integration ("Cloud Service Bus") Some ideas   * Development of common Web Services API's for SaaS providers (like all e-mail providers support SMTP and POP3, there will be a common CRM protocol and HR protocol)   * Development of cloud based broker services with capabilities such as message queuing, transformation engines, workflow engines, etc.


Should object oriented programming be the first thing students learn?

My high school is starting a program where, instead of following the 'traditional' method of teaching programming (learning variables, then operations, loops, methods, and finally OOP), students are immediately introduced to object oriented programming without any other programming knowledge. Is this a good idea? My personal view is that teaching OOP first is misguided - when I was introduced to OOP, I was able to appreciate the power it gave me when designing complex programs, as I was already familiar with procedural programming. Introducing students to OOP at such an early stage might make them ignorant as to the power and flexibility that OOP gives programmers. There are also the practical problems - students might have a difficult time designing classes when they have not been introduced to methods properly (how they work, when they should be used, etc.). I don't have many details about the course curriculum, but by my understanding, students are to be introduced to OOP by their third lesson, after having been taught variables and operations (as well as standard input/output). In case it's relevant, the language my school teaches in is C#.


When is it okay to ship a product with a known bug?


How to Make Sure Your Company Doesn't Go Underwater If Your Programmers Win the Lottery

I have a few programmers under me, they are all doing very great and very smart obviously. Thank you very much. But the problem is that each and every one of them is responsible for one core area, which no one else on the team have foggiest idea on what it is. This means that if anyone of them is taken out, my company as a business is dead because they aren't replaceable. I'm thinking about bringing in new programmers to cover them, just in case they are hit by a bus, or resign or whatever. But I afraid that   1. The old programmers might actively resist the idea of knowledge transfer, fearing that a backup might reduce their value.   2. I don't have a system to facilitate technology transfer between different developers, so even if I ask them to do it, I've no assurance that they will do it properly. My question is,   1. How to put it to the old programmers in such they would agree   2. What are systems that you use, in order to facilitate this kind of "backup"? I can understand that you can do code review, but is there a simple way to conduct this? I think we are not ready for a full blown, check-in by check-in code review.


How important are code formatting guidelines?

Coding standards are common in any software development organization, but how important are they to follow? I can understand the need for some consistency, but when dealing with simple things like the position of braces, line length, etc., I'm not sure excessively strict standards contribute much to software development. Isn't it more important that your code is readable, not that it conforms to a predefined standard? It seems they're more like... guidelines anyway.


What is the ideal number of displays needed for high productivity

> **Possible Duplicate:**   >  How many monitors do you use? Why? How they are used? Ive seen people mostly freelancers work with three or four monitors around them and it looks so cool. I personally have two screens in my office and i think it suits my needs well except certain situations where i feel that another display would have made it easier for me. So as a programmer/developer what is the ideal number of screens and display setup that would increase productivity. Will going to three or four screens decrease productivity as opposed to increasing it?


Horizontally positioned or vertically positioned monitor(s)?

> **Possible Duplicate:**   >  How many monitors do you use? Why? How they are used? With inspiration from this question, I thought I'd ask my own concerning monitors. Some monitors you can turn 90 degrees so that it stands vertically positioned. I've also seen this setup be used in some offices. But which is better for programming? The way I see it, horizontally you can fit more documents side by side, but vertically you can view more code of the same document. Which setup do you prefer? How does this scale with multiple monitors?