instruction
stringlengths
34
19.9k
There are some situations where I have no internet connection and so I am forced to work offline. Usually it would look like this: I get connected, do a checkout from source control server, and move out of office. The NuGet packages stay on the server, because I have enabled Package Restore and should have opened Visua...
An example of an association class is given here: http://pic.dhe.ibm.com/infocenter/rsarthlp/v9/index.jsp?topic=%2Fcom.ibm.xtools.modeler.doc%2Ftopics%2Fcassnclss.html Composition and Aggregation are also types of Associations, just with more defined semantics to what the association consists of. Can association classe...
i need to store a large amount of data - about 10 million entries of the format unique hash (64 chars), value 1 (5 chars), value 2 (9 chars) i will be reading and deleting (but not updating) this data in quick succession. for example, i might write 10 lines, then read 3 and delete 3 lines, before moving on to more wri...
I need to create a simple payments validator. On the following class diagram, I tried to present the model of payments. As you can see, each payment type inherits from Payments class. Now I want to work with these payments but hide the details so the user can only access what he needs. And those things are are: Load ...
Should the product owner ideally be as part of the product management team? How does one handle the internal stakeholding if the product owner is outside the product management team? We had problems since the product owner was not part of the product management team and there were lot of conflicts.
I am developing a media server, the basic functionality is to serve an image, which is done the following way /media/:id where :id is the id of the image. You may want to ask for a specific size, with some rules I will provide. Eg: /media/:id/50x50 /media/:id?witdh=50&height=50 Question: Which option do you think is ...
So I feel like this should be a common question but I can't find the answer. Maybe I'm using the wrong terminology. Assumptions: IDs are supposed to be unique across the document. Class attributes are meant for CSS and should not be used in JS selectors. Name attributes are not appropriate ID replacements since they d...
I was playing around with Java today and I read about static inner classes. Why can you have 'statefulness' inside of a static inner class. For instance: class outerClass { static class Test { private String a; String getA() { return a; } void setA( String newA) {a = newA; } ...
In the context of Network Socket , which one is the REMOTE SOCKET ADDRESS?? Does the Client Socket Address refer to the Remote Socket Address?
I have known about the weird dingbat fonts since the first time I tried to change the font on MS word and stumbled upon them. Since then I never questioned them, I just thought hey cool. Now I have some questions. What is the purpose behind creating dingbat fonts? Is there anyone/entity that actually uses/needs these ...
in the project I am currently working on we had three different types of prices depending on the age of the user (adult, child, etc...). So we had on the DB a table looking like this: PRICES type Amount A 20 B 15 C .. D .. At first we only had 4 different types of prices, so in th...
Although this question has come up before, mine is different because it is not supposed to cover anything OOP but only plain (ANSI) C. Especially in open-source software, I usually encounter a plethora of functions (please don't call them methods since we're not in OOP) with the static keyword preceding the data type. ...
I'm studying software engineering and one thing I'm really trying to improve is my skill in software architecture. My question is quite broad, so I'll try to explain it with an example. Suppose you have a model layer and a service layer. The model manages various entities (such as users, products, orders, campains etc....
Say I have the following types: type EndsTup = (Int,Int) -- (0-based index from start or end, Frequency) type FreqTup = (Char, [EndsTup], [EndsTup]) -- (Character, Freqs from start, Freqs from end) type FreqData = [FreqTup] -- 1 entry in the list for each letter Which I'm using to store data regarding the ...
I'm beginning my journey into graphics programming and want to learn OpenGL. Because I'm green to graphics programming but not to C and C++, a familiar question came up when I looked at OpenGL and ES... Is OpenGL a superset of OpenGL ES? I read in an ES 3.0 guide that it uses shader-based implementations that exist as ...
I am developping a desktop application in C#, and have separated different layers in an MVC-ish architecture. As I have switched from GTK# to XWT, only views had to be adjusted, so the seperation of layers was done quite OK. As XWT does not have a layout designer, everything has to be set up in code, which in turn led ...
I am looking to take my java certification very soon, and I have a question about the different types of associations described in the official oracle guide book. The book describes the 4 as the following: Direct = "has-a" Composition = "composed-of" Aggregation = "part-of" Temporary = method parameters or loca...
I often question myself of where to put the logic that organize the data to a view that is not necessarily a business logic in a 3-layered architecture (DAO, Business, View). I'll put an example to be clearer: I have a UI in my aplication that shows pending tickets and answered tickets in two different tabs. To get the...
I've read a few articles on the MVC pattern and tried to understand what it exactly is. But till now, what I get is a plain diagram showing 3 modules of Model, View and Controller. Some say that it helps increase code reuse (DRY), while I think it does the opposite. I currently separate my application code into differe...
Today I found an article about Java8's Fork/Join-Framework and its usage for the parallel streams implementation. While I do understand the article, I'm not entirely sure what I should think of it. Basically what it says it that F/J in conjunction with streams is next to useless, and especially so in the context of JEE...
I have 3 web services that are providing me data for my hotel booking engine. It is taking too long if I run them sequentially. Therefore I wanted to run them using threads, but I am not sure if php threading will support this and if it is safe, since all 3 processes that will handle the web service will read and write...
I'm developing a Django project that basically boils down to: A user submits a form. The Django view parses the form and compiles a representation of that form which is readable by some other 'function'. By 'function', I mean some kind of executable/callable where the Django view may be agnostic about what language th...
I'm building a web chat app using session to keep the time the app last polled so that the server can determine whether messages exist between the current polling time and last polling time. It works well however, there are few instances whereby the messages sent from client A is not received by client B or the same me...
Requirements I have Grid of unlimited size (I don't and can't know what its size) There is Object that should be placed on the grid, every object have hes stream distance (in other words: range, default: 300) and 2D coordinates (position) There is function find that takes 2D coordinates and should return what object a...
I want to provide different UI theme based on user who logged in. For that I have came up with following 2 options: Create separate files for all themes duplicating all the common CSS. This way I can easily do some login in scripting and get the required CSS file. But I end up having same CSS classes code in many diff...
Background I've run across this problem as I am currently an intern at a large company's local software division. I have been given the task of extending a project that several previous interns have worked on (not collectively but sequentially). The project is written in C# and is a relatively simple tool (codebase of ...
I'm writing a program that goes into a loop and keeps changing the state of some models (similar to a game). Naturally, many things are mutable. However, I'm also writing some classes that are immutable because they're inherently treated like values (for example: vectors, matrices, etc.) However, these values change on...
I have read that Java is pass-by-value, and I've been reading about it in this question at StackOverflow, but I'm still a bit confused, regarding the close() or shutdown() methods in various classes. What I want to know is, suppose that I do this: public Constructor(){ if(isProceeding){ InputStream iStrea...
we are at the middle of a project. It's a REST Service. Now we have controllers to handle the Requestmappings and the forwarding to the Services. A concrete example we have a UserController, GroupController, UserService and a GroupService. The user controller has as injection the UserService and the GroupController h...
Our security team at work did a security scan of our soon-to-be-deployed website and one of the items that was found was "Hidden Directory Detected". It shows up for 3 different folders, aspnet_client, scripts, and content. The software recommends to throw a 404 instead of a 403, or to remove the folders completely. Fi...
I'm trying to learn OGSi framework (Equinox distribution). I have registered my service, but I'm confused about a piece of code that I've copied: IAgendaService service = new AgendaService(); What does this line of code mean? I think that in the service object, there are the IAgendaService methods that I've implemente...
I have a 24 character long id which is guaranteed to be unique. I would like to shorten that to 7-10 (or even shorter) characters long. If I generate an short id randomly then I would have to check every time if that shortid is available. Is there an one-way hash algorithm that could return back 7-10 character hash fro...
As I was originally learning about MVC, the book I was using taught the following technique for Controller actions: public ActionResult MethodName(Model model) { if (ModelState.IsValid) { } else { } } However, I quickly ran across an unrelated issue, and someone on Stack Overflow pointed me to a new function i...
I have two objects which work together to provide interaction with HIDs on a machine. One object is responsible for the communication (read/write) to the HID and the other object is responsible for modelling the HID. Information is read and written to the HID as byte arrays. As a contrived example: class Hid { priv...
I have an object that contains a reference to another object of the same type. Example in PHP: class A { protected $child; public function __construct(A $child = null) { $this->child = $child; } public function go() { if($this->child) { $this->child->go(); } } }...
I was asked this question during a technical phone screening recently and didn't do well. The question is included verbatim below. Generate {2^i * 5^j | i,j >= 0} sorted collection. Continuously print the next smallest value. Example: { 1, 2, 4, 5, 8, 10...} "Next smallest" makes me think a min-heap is involved, bu...
I am looking for a hashing algorithm that works like this. I start with a text file, and compute its hash. Now I know that I will remove one character at, say, position 67 and this character is a "m", and I would like to compute the new hash without reapplying the hash function to the full text, but instead using the h...
I was researching about the gcc compiler suite on wikipedia here, when this came up: GCC started out using LALR parsers generated with Bison, but gradually switched to hand-written recursive-descent parsers; for C++ in 2004, and for C and Objective-C in 2006. Currently all front ends use hand-written recursive-descent...
I want to release all my future FOSS projects under a "public domain" license such as CC0. This is in order to avoid the requirement for attribution present in most FOSS licenses, mainly when the code is compiled into a binary, but also when somebody decides to copy a small portion of my code into their own open source...
Is it theoretically possible to transform every kind of general-recursion into tail-recursion? Are they equivalent for example from a lambda-calculus point of view? That's a debate between me and an acquaintance. My view is that it's not possible everytime. For example if you have a function which calls itself recursiv...
I'd like to get better at estimating how long it will take me to complete tasks. When estimating things I know little about, I think it's best to start with base rate information and adjust it based on things I do know, rather than to go on 'gut feeling' which is what I normally do, and is generally optimistic. What I ...
I'm currently working on a project to replace some excel worksheets. There is a lot of industry specifics that change quite often and nobody really knows how things should be but every sure enough thinks they know how they shouldn't be. Project Priorities: Maintainability - The business processes change frequently. Th...
I have a question for you guys. Say, you're given a task as an item in a product backlog. Say, you have a deliverable that's due the following day. If you're behind on the task compared to when you made your estimates, what do you do about it? Does it make you anxious knowing your behind schedule? How do you deal with ...
A friend of mine is working for a small company on a project every developer would hate: he's pressured to release as quickly as possible, he's the only one who seem to care about technical debt, the customer has no technical background, etc. He told me a story which made me think about the appropriateness of design pa...
I'm really confused by all the open source licensing details like "I wrote a web application, which should run on a computer not owned by me. My software uses the library/language xxx. Is this considered a software redistribution of xxx?". Looking at the first four pieces of used software reveals four different license...
As far as I know, C is by far the most widely used language for low level stuff such as systems programming and embedded. Sometimes assembly is used, but that's when you really need to be close to the hardware. My question is why doesn't C have any competitors in low level development? It might be my ignorance, but I'm...
Suppose you have a reasonably large codebase (0.5 - 1 msloc) with a large test-suite (6-7hr single-threaded runtime; with a mix of unit-tests and integration-tests built with different tools). You have a proposed patch (or diff or pull-request) for the codebase, and you want to automatically run the most relevant test...
I've just put together my first app using Zend_Authenticate. According to some tutorials I've read they store the user's "email" column. Is this recommended? I've read to store the ID only, then on each request fetch the user by ID. That way, only the ID is stored in the session. Is this recommended with Zend too? Anyw...
I'm reading books on JavaScript programming, and I need an environment like Python's IDLE to type JavaScript commands into and then see the results like you would in IDLE. Is there an environment where you can do such a thing?
The question how-do-you-organize-your-projects already has a few good answers. I would like to get a better understanding about this suggested structure: MyApp.Core MyApp.Model MyApp.Presenter MyApp.Persistence MyApp.UI MyApp.Validation MyApp.Report MyApp.Web Assuming MyApp is a winforms rich client to administer stud...
We have a textarea field in a desktop client server application which in the end stores all the data in a database server, this text area is used to take notes and similar text areas have been put throughout our application as a marketing choice so that users can never blame the application for missing some fields and ...
This is not a question about how to number versions. We have an application with a certain version numbering scheme. We also have a Jenkins CI server (soon to be replaced with Atlassian's Bamboo) that regularly builds our software. The application displays the version number, so it's written in one of the files in our ...
If you want first element of list or array you reference it as 0 in many languages (like C or Clojure). Is there are some really good reasons why the programming languages was design this way? In old days in assembly languages it makes perfect sense because all possible values needs to be used. But what are nowadays t...
The Common Lisp spec states that nil is the name of the empty type, but I've never found any situation in Common Lisp where I felt like the empty type was useful/necessary. Is it there just for completeness sake (and removing it wouldn't cause any harm to anyone)? Or is there really some practical use for the empty typ...
Many questions have been asked about the nature of elegant code and design, but the underlying assumption seems to be that elegance is a good thing. Therefore it is acceptable or even desirable to make some extra effort to create elegant solutions. But is it really worth it? I am not asking what is elegant; neither am ...
I have three column as follows: Month Tech Circle According to this column I need to fetch the data. In Month Column, Data is : Jan,feb, March... and so on. In Tech Column, Data is : Gsmnqi, Gsmboi... and so on. In Circle Column, Data is : Ap ,Kol, Mumbai.. and so on. I want to prove four condition as follows: if I ...
Some programing languages, notably Pascal, have a type of numbers called "real". However, mathematically speaking, these types aren't real. For them to be "real", these types have to be able to represent any real number. Real numbers like 1/3 and irrationals, however, can't be represented in floating point. So why do s...
I started working in a company not much time ago, and what I see a lot inside a project is a high amount of low quality code and some custom ideas instead of industry standards and selected best practices. But when I trying to talk with manager about that, I often see the answers, that guys who doing that make things q...
Scenario: I have a configuration file containing some structured data that is loaded in at runtime and is not modified by the application, but is referenced in many places. There are functions that retrieve specific data from the configuration file (after it's been loaded into memory). I'd like to write unit tests tha...
I have Client which uses a disposable Connection for talking to a remote service. A Connection is somewhat expensive to set up and needs to be Dispose()d properly. I want to allow multiple methods in Client to share a connection, like this: using (client._connection = client.Connect()) { client.SyncTime(); client....
I have a Route that activates a Controller which returns to me a page through a View. Let's call it master page. route -> controller -> view [master page] The master page is divided into header, sidebar, body and footer. And as the sidebar can be loaded to other pages, and not only the master page, it has its own Vie...
I'm sorry if the title is a little hard to get. I've never built an entire big software my self, just some small apps in my free time, i was more familiar with the do-what-my-boss-told-me things. And our approach is a little amateur, obsolete also (Foxpro 8.0 and MS SQL 2000). Now i've started to work at another comp...
I have been trying to solve this problem for sometime now. This is regarding django web development. I have an HTML page which has a Javascript function to upload an image file from the users local computer. After that file has been uploaded on to the HTML template, I want to use the uploaded image file for further pro...
I'm searching for a suitable way to make web requests to databases and display results in real-time. The data will be used in an interface for staff, so there cannot be any blocking or lag as time is a key factor. So far, I've been using PHP for the backend of the system. However now that I've come to the interface, I'...
I created an action bar icon for an Android app I'm working on and it seems to downscale my icon. The thing is, it isn't a square icon. The width is greater than the height. Do I really HAVE to provide square icons or is there a workaround for this? I don't really want to ditch my icons just because of this...
I have a slightly old PHP project I'm working on for a client (I think it was started around 5 years ago), it makes extensive use of the outmoded mysql_query function, which is concerning not only because it's now deprecated but because it could also open security holes. The project doesn't seem to have much of a struc...
I'm coding a game in my spare time, but I am mostly still a beginner when it comes to programming. I'm sorry if this question is off topic or if it ends up not being helpful to anyone else, but hopefully it will be. I've spent a lot of time reading books about the design of code, as well as different methodologies an...
Honestly, I can't help but feel that this is done merely to confuse newcomers. Most of the errors on Stack Overflow by complete Android newbies mostly stem from that they have a static inner class Fragment that they don't understand how it works, why it's there, and try to use Activities even though they don't fully un...
Assume a method with the following declaration public IList<Location> GetLocations() { ... } I write (at least) the following tests Check to see if the method returns an empty collection if no locations are found. Check to see if the method returns the correct number of locations. Check to see if the data in the loca...
I am building a game based on PHP and MySQL. There is a player-vs-player mode but I figured I should add a player-vs-computer mode as well, since players may not be online at all times, especially in the beginning. It is a combat type of game where players have up to two characters and can fight each other, taking turn...
Two of the most popular dynamically typed scripting languages, Python and Ruby, do not make a distinction in syntax between the declaration of a variable and assignation of a value to it. That is in both languages, declaring a variable n and assigning a value to it would look like so: n = 10 And assigning a new value ...
In Haskell, the Functor typeclass functor is defined as follows (see e.g. Haskell wiki): class Functor (f :: * -> *) where fmap :: (a -> b) -> f a -> f b As far as I understand (please correct me if I am wrong), such a functor can only have as target category a category constructed using a type constructor, e.g. []...
I often end up with code files that can either be imported or run as __main__. It's easy to handle this by checking if __name__ == '__main__'. But sometimes if my main function gets too big I split out pieces of it into other functions, expecting that they'll only be called when __name__ == '__main__'. Sometimes I enfo...
This is related to DDD for a desktop application in c#...with 4 layers ui/application/domain/infrastructure. Actually 3 desktop applications sharing part of the domain and part of the infrastructure. In an effort to avoid developers crossing the wrong layers and using the wrong classes, I separated the layer in assembl...
Is it a bad practice to give two very different files with the same general purpose the same name, separating them into different directories? <script src="client_scripts/app/player_stats/generator.js"></script> <script src="client_scripts/app/coach_settings/generator.js"></script> I'd like to keep my file names short...
Problem: Given a list L of objects of possible sizes from set S={1,2,4,8} and unlimited supply of bins of sizes 16 each and we have to use minimum possible numbers of bins to pack all objects of L. I am also searching for an optimal (or near optimal) solution using dynamic programming or otherwise in the following sce...
I'm designing a data structure in C++, and I want to expose an interface to the user to traverse the structure in some order. Instead of creating several different types of enumerators, I want to keep it simple and provide a single enumerator, while maintaining const-correctness. My design is summarised as follows: cla...
I´m working on a mod update checker for minecraft, but there is a big problem: The modders and online database that I´m using for update checks has no standard software versions e.g.: Local: rv0-stable-10 Online: rv1-alpha-13 Local: R1.1-83 Online: r1.1-81 Local: 1.7.10-0.2.250 (1.7.10 is indicating the Minecraft vers...
I'm writing a JavaScript graphing library using canvas which I am licensing under MIT, and I'm using jQuery, as well as a couple of other open sourced libraries, all under MIT. I'm also using bower to manage my front-end dependencies. How should I best handle these dependencies without violating the license? Preferabl...
The question title is probably too abstract, so let me provide a particular example of what I have in mind: There is a webservice that encapsulates a process of changing passwords for users of a distributed system. The webservice accepts user's login, his old password and a new password. Based on this input, it can ret...
Here in Brazil we have a personal identifier called CPF. This identifier has a sequence of 11 digits and is unique for each Brazilian citizen. Possibly in other countries there is something like that too. How is a unique identifier, I chose to set it in the database like a UNIQUE KEY. And now that things get complicate...
I'm currently in the process of creating a Skype-like program, that uses a hybrid peer to peer system to communicate between users (i.e. server contains all users IPs, a client that wants to connect to a friend will tell the server, that will then send each client the other's IP so they could start hole punching to est...
I am looking to understand and implement the Onion Architecture and have a vague idea on how to structure everything but need help to clear up some of my confusion. Based on different examples and articles I Have read I created the above structure. One of my main confusion comes when I look at "02-Service: Services I...
I'm working in a java role after working a couple years in functional programming. Our company was bought by google and I took a java role after the acquisition. Coming back to java as a polyglot developer, I'm generating getters for immutable objects and I'm seeing it's a total hogwash. Are there any reasons why the ...
So Referential integrity is good, but are there scenarios where not having constraints is better? For example when all the logic of relationships is kept in code? or when the database upgrade is simplified? PS: I am not asking it is good not to have referential integrity, just that what scenarios would justify it
I'm not quite sure how easy it is to fetch the binary composition of a file, but suppose we have some file with this representation: 010011 We could make 2 arrays. One which stores the position of the 0s: ['x', '', 'x', 'x', '', ''] And another which stores the position of the 1s (which is simply the opposite of the pr...
In a project that I have started working on, the database has a lot of FooDefinition tables which act like an enum. It's a C# project using Entity Framework although that is not central to the question. The entities have an ID, a string Name field and an int Type field that is converted to an enum. For example: public ...
To my basic understanding, software licenses only apply when redistributing software. Even if I am wrong about this in general, the GPL states that you need not agree to the GPL in order to receive or run a GPL-covered program. Say there is Program X. Program X requires Library L to run. Program X is covered by a GPL-i...
I have a main View which has several sections and a main dropdown at the top which defines how the rest of the view looks like. All these sections have some data that is visible all the time, and some that need to be hidden when certain values are chosen in the main dropdown. As of now, I have partial views for each se...
I'm new to web-service programming, and I'm unsure of a few things. I know that REST web-services can be used to interact with the system like this: to retrieve a user: GET /user?id=1 to retrieve all users: GET /user to insert a user: PUT /user?{all user data} When I need to do an update action for some tables using ...
My background is the book BDD in action. How one goes from Feature to Stories? More specifically I would like to understand the following: 1- When does one provide the decomposition into stories? Do you do it while spotting the examples that illustrate your feature ? 2 - If so how do you proceed in your development the...
I'm newbie of web services programming and I have some problem to understand how to work authentication/security for REST WS pattern. I had read about OAuth but I haven't understand how it work in detail, however I think I don't need it because only my app use the API. I need authenticate the users that need to use the...
In the application database there is a configuration table with this schema: Table: ReleaseProperty ReleasePropertyID ReleaseID Name Value Currently to retrieve a specific property I pass to the Repository class the arguments ReleaseID (that come from the current web page address) and a Name, that is basically hard c...
The purpose of the Accept header from the client is to tell the server what kind of data it will accept as a response to its request. We can set this header in asynchronous HTTP calls in Javascript, but not in HTML. For example, consider a link such as <a href="/some/resource">Get as CSV</a>. If an attribute like acce...
I'm working on an application that does lots of encryption and decryption in-application and this is probably the number-one bottleneck, so I've been spending some time making performance tweaks to it. A lot of this has involved simply caching things in memory (I realize there is something of a security tradeoff in do...
Tl;Dr Given a language with no polymorphism how to you elegantly modify the behavior of a leaf in a tree data structure. Context I'm programming an application in C for a microcontroller and I'm wondering what would be the best way to design flexible GUI-less menus. Basically inputs may come from 2 different sources: T...
I'm new to C# programming, I was experimenting with iterators concept in C#. Here, I'm trying to display all the terms in a list, for that I'm trying different ways to obtain the results. In the below code, I'm using two classes ListIterator and ImplementList. In the ListIterator class : I defined a HashSet and it use...
The database I'm currently building is pretty traditional relational database stuff, but there is one requirement that is not clear to me how model appropriately. There are many business rules which are translated into database consistency checks (i.e. date A must be between date B and C or this field must be not null ...
In static languages like Java/C#, I commonly make use of constants for strings or numbers, rather than insert them into the code alone. However, I tend to avoid this practice in JavaScript. More recently, as some other coders around me have taken this approach in JS, I decided I should probably solidify either my, or t...
I have been taught that shifting in binary is much more efficient than multiplying by 2^k. So I wanted to experiment, and I used the following code to test this out: #include <time.h> #include <stdio.h> int main() { clock_t launch = clock(); int test = 0x01; int runs; //simple loop that oscillates bet...