instruction
stringlengths
34
19.9k
Suppose in some ORM based project (say Hibernate) I am trying to fetch only few columns rather then the whole Object with may be more than 20 attributes. I am writing HQL like "select attr1, attr2 from Entity ". I know I am not taking advantage of using Hibernate because I will get the result in Object form only and th...
I'm working on a small team that will begin working on a large new project with another small team. The other team is currently working on a legacy system that they have been working on for years. The manager has decided that the developers from my team will be rotating every few months to replace developers working o...
When modeling a chat, should a chat object receive messages or a message be sent to a chat object? I'm not sure whether there is a definitive answer but maybe someone can point out benefits of one over the other. message.send(chat); VS. chat.sendMessage(message);
I have 3 classes: Meeting, Project and Agenda. A Project contains all sort of information + a list of meetings. The Agenda contains a list of upcoming Meetings. A Meeting contains some data + a list of Projects that were discussed there. The Agenda checks for upcoming meetings. When it finds one, it calls its Meeting...
I am trying to simulate SQL joins using java and very large text files (INNER, RIGHT OUTER and LEFT OUTER). The files have already been sorted using an external sort routine. The issue I have is I am trying to find the most efficient way to deal with the INNER join part of the algorithm. Right now I am using two Lists ...
I'm trying to rebuild a simple c# time tool that displays certain statistics about time worked for the web, however, I don't have access to a server so I can't use server code like PHP which I would do if I could and this task would be a doddle. The employee's work information is stored on an intranet site that the C# ...
I've been using C# for a while now, and for the sake of furthering my career and extending my knowledge of programming, I want to get into C++. C# is very useful, and fast to work with, but since my team and I will be making large scale projects I need to consider working at a lower level language for several reasons. ...
Our small team has made the curious observation that diagnosing and fixing broken automated tests is a useful activity; in particular, if the CI build indicates that developer A's last check-in broke some tests, developer B can learn about (and possibly improve on) what developer A was doing by understanding why the te...
Background Developing a system for creating eBooks. The data is highly normalized. The eBook designs are packaged as "themes." The themes can be configured with options for: fonts, colours, some layout, and thematic elements (such as squares for bullet lists could become circles, hexagons, or arrows). The options are t...
Ive just started working with Git (Github) in anticipation for an up coming project I'm project managing and designing and developing the front end of. One thing I couldn't work out is, is it preferable to publish each individual change as you make them, ie. updated sidebar js, designed new FAQ page (each as individua...
Over the years I have assigned values to classes and html elements in all sorts of ways: myClass MyClass my_class my-class . . .and so on. As I am always trying to hone my craft and make my code more readable for others, I am going to discipline myself to stick to one convention moving forward. I am leaning towards...
What specific conditions or requirements should you create your own array over using std::array? Here is my background: I'm developing a small simple library that a small group of people will use and hopefully build upon. The current structure allows for both std::vector and std::array using iterators, however, a lot o...
Android source code and many Android open-source apps and libs use m prefix for member fields and s prefix for static member fields: private static boolean sStarted; private long mTimestamp; I personally dislike this, because it looks ugly and it's redundant – my IDE already uses different color and formatting for loc...
So, as Microsoft has created many forks and branches off of .NET, there have been a few different product names come up: Silverlight .NETCore/WinRT/.Net for Windows Store Apps .NET for Windows Phone/CoreCLR .NET Micro Framework .NET Compact Edition However, what do you call the traditional .NET we all know and love? ...
I am a front-end developer who barely even see a file with .h or .c extension. I know basic C syntax, I've learned it in Unreality but never was interested in such low level programming because it was simply too much setup for simple things. I am very interested in learning all aspects of Computer Science but I want ...
The theoretical situation is this: Let's say that we have a digital dictionary (by which I mean a traditional list of words and definitions, not an associative array). For the sake of simplicity, let's also say that each word can be replaced by its exact definition, and still make sense in a sentence; for example, if ...
I have done a huge ton of reading up on Simplex Noise now, and after a lot of confusion and headaches I think I am able to form an idea of how Simplex Noise works now. Am I right, that simplex noise (2D) is just a grid build of Simplexes, in this case triangles, where at every corner of a triangle there is a value bet...
I thought I was doing breadth-first graph search correctly, but my instructor's grading script is telling me that my answer is incorrect. From the instructions: Consider a breadth-first graph search on the graph below, where S is the start and G is the goal state. Assume that ties are broken alphabetically (so a parti...
My background is back-end server development. Very back-end. Now I work in a position where I need to also take care of front-end. Nothing fancy but I need to be able to code for front-end as well. As I said no fancy stuff as I am not a designer. I know some very basic stuff about html/css/js but most of the time I...
I understand it is better to automate BDD specifications below the user interface whenever possible. For example and quoting from Gojko Adzic's book: Specification by Example: Don't check business logic through the user interface My question is then: What are the specific use cases when using the UI layer does make s...
I was in a conversation with someone who codes for me. He was frustrated with my approach to a particular problem. I am entirely self taught and very pragmatic - I am not a professional developer instead I sometimes write code to get something done and then pass it on to him to clean it up - make it robust etc. We ...
I have been working on a system alone for about two years. I inherited the system from a contractor who spent about two years working on it before me (alone). The system is not particularly well designed because there is business logic, presentation logic and data logic mingled together. It is a very complex system, ...
I'm working on a system that allows Administrators to define Forms that contain Fields. The defined Forms are then used to enter data to the system. Sometimes the Forms are filled by a human via a GUI, sometimes the Form is filled based on values reported by another system. For each Field, the Administrator can define...
Naming a variable or class, for example, must adhere to certain rules (such as not allowing keywords or reserved words as identifiers) I really don't want to code my own method to do such a thing. Does java have something already built in? My goal is that I am building an expression builder / code generator. It will re...
It was funny for me, and I'm interesting the reaction for this question of the community. It was interview for C++/Qt developer, and question was asked "What is virtual function". Not something like "how polymorphism in C++ works" or "how virtual functions works" but what is. My first thought was to answer "Virtual fun...
I learnt some about pipelining but those were 4-stage and 5-stage and I think that modern pipelining typical is much longer and more complicated in practice. How long are typical pipelines and how much can we expect them to increase and where is the point of reaching diminshing returns in performance gains for longer p...
A word processor is a complicated creature of many layers and pieces, but it represents a relatively simple concept: a piece of paper with writing on it. This leads to the problem of having many abstractions without enough intuitive names to describe those abstractions. Not everything can be a document. The solution to...
I'm rather new to the broad world of Git. I have read the manual and have been practicing but I am confused about few aspects of it, which I couldn't figure out after searching for. I'm wondering: In a project (post first commit), when is the right moment to stage source files? Right before committing? Right after add...
First of all, pardon the title, as it's not very clear. I have an application I am writing that is GPLv3, and is in Java, which means that classfiles are generated and linked to for general operation. I am also using a scripting engine which, for performance, links any scripts it runs to my program's scripting librarie...
I have an app for creating simple graphs (the kind with vertices and edges) and then using different algorithms on them (BFS, DFS, topsort, Prim's etc) for demonstrating how they work. I'm now working on porting it into a Rails app and deploying so it can be used by my university (hopefully). Currently the graphs are ...
I used to work in a waterfall methodology and now I am in a team that is following an agile methodology. It seems they are doing it wrong. For example, we have stand-ups that last 25+ minutes daily, which is really annoying. Additionally, I feel more like I am justifying my salary to management than anything else. Am I...
I have a few sites which are all hosted on the same web hosting service under shared hosting. My web host supports Git and I have SSH access to it, and I also have Git setup on my laptop as well. I want to make it so that when I do a "git push origin master", it will automatically update the files on my web server, an...
I am familiar with Agile and Pair Programming (http://en.wikipedia.org/wiki/Pair_programming). I thought Pair Programming was used if there was a complex requirement i.e. two sets of eyes is better than one. Is Pair Programming also used to train less experienced developers and bring them up to speed? Also, how often ...
Most of my client side code ends up as a long script in one file the mostly looks like this: <script> function someFunction1(){/*...*/} function someFunction2(){/*...*/} ... var globalVariable1; var globalVariable2; ... $(function(){ $('selector1').click(function(){ //get relevant data from various DOM elements ...
What techniques are there for debugging remote client side errors in a web application, especially when they only affect a small subset of users? In my case we have an app that is working well for hundreds of users, internally and externally, but a handful (12) have a specific problem with a JavaScript that prevents th...
Even though I've programmed on a professional level for some years I still do not fully understand error handling. Although my applications work fine, the error handling isn't implemented at a professional level and is a mix and match of a number of techniques. There is no structure behind my error handling. I'd like t...
what is the simplest and fastest way to support simple scripting in a .Net application? I search a lot but only find many things with practical no documentation or outdated since years. I only need to transfer a simple .Net Object to the script and get a bool result from it.
This is the link: https://gist.github.com/jgarber/2302238 I am new to github and web development.So please bear with my questions. I would like to use the responsive video code on the link mentioned above, for a commercial website I am building. I see that the code is posted under the 'public' section but there is a c...
I am trying my hand in python, Django, JQuery.. etc to make a clone of imdb site. Currently I'm in web-development from past 10 months on same technologies. In my spare time I want to develop a side-project which may look good on resume. I came up with an idea, to make a clone of imdb.com. But after 2 weeks of developm...
My main problem when trying to form a program is that while I have the tools at my disposal, I am too disorganized to properly use them to solve my problems. Often my process is simply trial and error until the program works. I am looking to see what others use to organize the process of writing programs.
A little bit of background, we've made an electronic POS system for registered vendors of items of a well known brand. The vendors are required to login to use the system. Recently, IE has been giving us lots of painful maintenance problems than before. Our boss is getting worried about running into further maintenance...
I am new to web programming and just started learning XML and AJAX. I am creating a social gaming website for my college project. I am confused at the point of using XML for AJAX in HTML5. As XHTML is replaced by HTML5 so is it ok to use XML or i should choose JSON (i know nothing about JSON but it is what I found in a...
I have a question about CA1819 msdn performance warning. The rule is: Arrays returned by properties are not write-protected, even if the property is read-only. To keep the array tamper-proof, the property must return a copy of the array. Typically, users will not understand the adverse performance implications of calli...
The big question I have in my mind: how many developers are brownfield ("enterprise") compared to greenfield (all new code, from the ground up). I'm constantly reading breathless articles about the latest technology, only to find out that It Just Won't Work On Our Enterprise Software codebase. People aren't ready for ...
I know Lisp and Haskell are logic and functional programming languages respectively, but what exactly does this mean? How do they differ from other languages? I've heard that learning these will make you a better programmer and improve your logic. Is this true, and if I go learning Lisp or Haskell to a competent level ...
I have several algorithms that I would like to test against the same data sets to compare their results. I don't know how to design it so there is maximum readability and maximum efficiency. I have considered creating a class for each algorithm, and giving it a copy of the data to work with, but it doesn't seem that th...
Which is the preferred test package structure for packages containing subpackages: Tests in Subpackages? a/ __init__.py b.py c/ __init__.py cc.py test/ __init__.py test_cc.py d.py test/ __init__.py test_b.py test_d.py This structure suggests that each subpackage is a cohes...
My team is wanting to migrate away from compiled code to dynamic code. We have a wide variety of customers and each has different business rules. Instead of having a single compiled code base, we are considering having different templated script files for each customer. However we have a lot of compiled code, so for no...
When building an application one considers the appropriate technology of choice for best long term impact and scalability. If building a media streaming application for mobile and desktop should one still use flash or silverlight, or html5 and javascript? How does one select the right technology?
I'm working on a Python project that is executed on a terminal (or console) for which I am planning to implement a GUI. I did not major in CS so I really have no idea how to effectively design a terminal GUI such that: the user interface looks good in GUI, it is directed to a certain widget, let's say, a text label, o...
Is there any time CType() is the proper option over other methods? I did plenty of thinking on this myself, but wanted to put the question in hopes there would be answer to my question so I can put the question to rest in my workplace. My idea is that CType() should never be used. But others seem to think it's still a...
Hello I have been using C++ and Java for years. For better or for worse, I have always looked at JavaScript as not as powerful as these languages and therefore probably not worth my time and effort to learn. However, I have recently been more interested in web development. I have researched Rails, MySQL databases, Htm...
I built a web application using PHP. Now, I want to sell this web application online for customers but I want to guarantee that only one customer (only one website) use this. Is there a way to make the script under a license (which I provide)?
Backstory: As the single developer with experience in the chosen technology, a month ago I drafted a component that for all extents and purposes worked within acceptable levels according to the demos that were had. Four weeks and assorted developers later (that´d be more or less last Thursday), the feature entered Q...
If I'm a senior project manager, should I still keep learning new technology? For example, every month every year, most language updates themselves, and a lot of new programming concepts become popular. Many new frameworks and patterns are created and make things easily. But you have to spend a lot of time to keep up w...
I have an assignment to convert various language descriptions into NFAs and DFAs. Having graduated with my CompSci B.S. years ago and not touching the topic until my M.S. program, I am racking my brain on one of the questions. I can easily construct a DFA, but the answer must be an NFA that is not also a DFA. I am not ...
I have been considering this approach for a project I am about to embark upon and would like to hear from other programmers about their experience in contributing code for equity. Has anyone been truly successful in such an endeavour.
I lead a development team and I want to release our product as often as possible (Continuous Delivery). In many cases, we have to implement a feature that takes longer to implement than the time between releases. I still want people to commit their code on a daily basis (Continuous Integration). Many times implementing...
I'm wondering what the best data structure (for storing data on disk) is for storing immutable time-series data (99% of the data is truly immutable, the 1% is metadata that is separate from the immutable data). I've been looking at log-structured merge-trees in particular because of it's heavy use by Cassandra and the...
AFAIK, Scala and Clojure are implemented in Java and Java is implemented in C. I suppose that many or most languages are implemented in C, for instance Perl, Python and SQL. I don't know much about language implementation but maybe you can tell me the rationale to favor one implementation language Java over another C? ...
So I was wondering today, where would you put utility classes in an ASP.NET MVC app? By utility classes I mean classes that can be static and are just used to perform a function. Like a class to send an email that takes email address , subject, and body as arguments. I would assume maybe creating a separate folder and ...
I've been heavily using a pattern for years now, but I don't know what it's called. It looks like this.... class xzy { public function getFoo() { if ( undefined(this.foo) ) { this.foo = new Foo; } return this.foo } public function setFoo(foo) { this.foo = foo; return this; }...
When you have a function that wraps another one in Scala. What do you call the nested function? I found this : def factorial(i: Int): Int = { def fact(i: Int, accumulator: Int): Int = { if (i <= 1) accumulator else fact(i - 1, i * accumulator) } fact(i, 1) } I usually use just do bec...
Here's what am trying to do (and searching for similar hasn't shown any results anywhere): On my website - provide an input box which will search google for results. I want to display those results on my page and customize the URL of those search results. So whenever a user clicks on the displayed result, my applicatio...
I had a look at XSLT for transforming one XML file into another one (HTML, etc.). Now while I see that there are benefits to XSLT (being a standardized and used tool) I am reluctant for a couple of reasons XSLT processors seem to be quite huge / resource hungry XML is a bad notation for programming and thats what XSLT...
Our team is currently facing a situation where we are changing a feature that is in the product today. This feature has Selenium automation tests associated with it. We are performing a fairly major overhaul of the system, including its UI. We expect this work to take quite a few sprints. During this time, other teams...
In the code I am working on, there are a lot of really small objects like: class HasFieldLameSetter { public: HasFieldLameSetter(field& p_):m(_p){} void set(bool p2) { m.hasLame = p2; } field& m; }; Having lots of small classes creates a hard-to-re...
Haskell often provides two versions of a given function f, i.e: f :: Int ... genericF :: Integral i => i ... There exist many standard library functions with those two versions: length, take, drop, etc. Quoting the description of genericLength: The genericLength function is an overloaded version of length. In particu...
Now that I've gotten into a dependency injection groove, I find main methods for different applications all look basically the same. This is similar to stuff you might find on the Guice documentation, but I'll put an example here: public class MyApp { public static void main(String... args) { Injector inj =...
I need to update a software framework once it has been deployed. The framework we are creating is made up of .NET 4.0 libraries (in Visual Studio). This common set of code libraries will be available for 2 .NET Windows services, a standalone .NET application, and a .NET MVC 4 website. (The services will run on a singl...
Does an in-code enumeration provide a stronger domain model than a static database table? As an example, say I have an Marble entity, with a Color attribute. The color attribute has a finite set of possible values—say red, green, blue. Say the database team recommends having a static S_ValidColors table, to the effect ...
I found this question at codility.com, but I don't understand the question. Can you help me figure out what do they want? I am more interested in the theory than a code. A non-empty zero-indexed array A consisting of N integers is given. A prefix_suffix_set is a pair of indices (P, S) such that 0 ≤ P, S < N and such th...
In C and C++, the main method holds the filename in the first position of the array at argv[0]. In Java, however, the filename is not included in the args string array. Is there a practical reason for this? I understand that this makes iterating through command line arguments 0-based instead of 1-based, but is there a ...
We have a closed-source commercial C++ application. Some of our logged error messages are in plain English like "ERROR: could not read file 'foo'". While others use a macro to print filename/line information like ""SplineReticulator.cpp(423): out of bounds". This is not an assert or a crash, the application recovers fi...
There are lots of projects released under more than one license. One example is Mozilla's tri-license, which states that the Software is released under the MPL, but the user can also choose GPL or LGPL instead of MPL (I think this is because the MPL license is incompatible with the GPL license). However, I came across ...
I've been working on some MSTest automated test infrastructure, that is testing a tool that merges data sets into SQL Server database tables. The basic structure of the test is to: Define the incoming dataset using anonymous types Apply the data using the reconcile tool Read records from the output tables Compare res...
I am building a software and trying to learn the typical steps for software life cycle, I am not sure if what I did is correct or enough so I would like to ask for the typical steps you follow during your life cycle in terms of actual steps taken for example requirement gathering is a not the step i mean, but gathering...
Given a class that implements an interface, but does not need all of the methods implemented, what is the best practice for unit testing this class with respect to code coverage? - or is it considered a sign for a code smell? To make the problem more concrete, consider a Java class (the question is not limited to Java ...
I am using state pattern on 28 states in my application. The states are for membership cards that has 7 major states, there are 4 boolean attributes for the membership card that actually affects the its behavior so I have decided to embed them with states, that's how it multiplied to 28 states. The problem now is with ...
Procedural code gets information then makes decisions. Object-oriented code tells objects to do things. — Alec Sharp So, when a view wants to display some information that is suppose to be derived from properties of a model it is displaying, should the calculation be part of the model or the view? Ideally the view ...
I am about to start User story sessions in my team. It's quite new for them and I am also wrestling with certain things. For the current project we have some well worked out wireframes. I read a lot about the way of writing user stories. What the template should be like and about different aids like Invest The plan is ...
I don't understand why a static method can't use non-static data. Can anybody explain what the problems are and why we can't do it?
I'm trying to figure out why going to 64 bit processors is such a big deal in an iPhone. I understand that there will be twice as many registers so the processor can work with twice as much data which should increase performance. However I don't see many phones going to more than 4GB of memory any time soon. It seems ...
The R&D team I'm in has decided to adopt a coding standard. We have only recently formed, and have too little code and common coding time of our own to base our standards/conventions document on what has developed organically in our team, and on good examples from our own code etc. Now, every one of us has some experie...
I have been working on a library which contains a large set of functions. For the sake of simplicity, I am going to use just one set as an example. I am not sure which is the better way, in terms of ease of use and performance, whether I should put those methods provided as individual methods, prepended with the functi...
I have been playing with Scrum methodology since year and half. I am using VersionOne as scrum tool. I have tried to follow most of the scrum principles. Sometimes, I feel like there is an issue with transparency of the stories. As of now, the whole team can get an access to all stories defined for the project. This cr...
I've had interviews with 5 separate people over the past two weeks and three of those five have all asked me this question: Explain what happens between hitting "Google.com" and the page coming up on the screen. Basically, how the Internet works. I figure after three times that I better be prepared if I ever get thi...
When discussing APIs between systems (on the business level) there are often two different point of views in our team: some people prefer a more - lets say - generic abstract approach, other a straight forward "concrete" approach. Example: the design of a simple "person search" API. the concrete version would be searc...
My team is writing a compiler for a domain-specific language (DSL) which will be integrated into an IDE. Right now, we are focused on the analysis phase of the compiler. We are not using any existing parser-generators (such as ANTLR) because we need real-time performance and highly detailed error/warning/message inform...
I was just wondering if there is some better way how to handle system "static" configuration data. Let say you have a system which offers several operation which are in code translated to operation code but you need to keep other related information to that operation like description, priority etc. Nasty way I have see...
I am working on a project that has two interface (web and desktop), they are not performing the same tasks but they use the same BLL and DAL, the web part using 100% of the BLL and DAL, while the desktop only needs to know about 20% of the BLL and DAL. Do you think it is a good idea to let the desktop use the same BLL ...
I'm about to create a new open-source project and I'm not sure about the licensing method I should choose. Here is what I know: The project will be built on the basis of an already existing open source. I will fork from the original project and will build a community around a new project that has a code base from the ...
Let's say I have a namespace my and this namespace contains a class foo. What should I prefer nesting typedefs into my class or hold it in my namespace? namespace my { class foo { // some stuff // nested one typedef bar my_foo_bar; }; // or namespaced one typedef bar my_foo_bar; } Looking at the std-libs ...
Intrigued by Flow Based Programming a la J Paul Morrison. I wonder if one can implement FBP in Excel/VBA. I searched quite a bit for a Basic-Lang FBP implementation to no avail. I've looked at some FBP implementation details in Python but I'm not grokking it. VBA is what I'm most familiar with, but I'm suspicious that...
I am constructing a program that does several things. Listens to a port. Every second a string is received When new data is received, it has to be logged. No errors or skipped entries are allowed When data is received, a plot on the screen has to be updated. This is an expensive computation. Missing some updates is n...
Problem: I'm asked to prepare a document where all our DB tables are listed and I'm supposed to list all Controllers that uses these DB tables for read and another list for Controllers that do write operations. Ex: +------------------------------------------+------------+ | DB table ...
First, there are many similar questions here, but I found none with direct answers about this specific scenario. If you find a duplicate, please be kind enough to link to the specific answer(s). Also, to avoid question being too broad, consider this specific scenario only. Assume a proprietary Linux application, which ...
I just started writing some new class and it occurred to me that I was adding a lot of method arguments that are not strictly needed. This is following a habit to avoid having state in classes that is specific to some method call, rather than being general configuration or dependencies of the class. Doing so means that...
CPython implementation detail: In CPython, due to the Global Interpreter Lock, only one thread can execute Python code at once (even though certain performance-oriented libraries might overcome this limitation). If you want your application to make better use of the computational resources of multi-core machin...
I feel uncomfortable when using query string parameters as: http://xyz.com/default.aspx?carId=1129&country=uk&uniqueId=98745DVF4563VVf1259 I would rather use something that should not make sense to anyone who is trying to make some sense from the URL: ?a=1129&b=uk&c=98745DVF4563VVf1259 (after all this query sting info ...