instruction
stringlengths
34
19.9k
I see most developers using switch statements with breaks in each and every case. Is this usage of switch statements inappropriate since a simple set of if-else statements would suffice? Is it OK for me to think that the only reason for you to use a switch is because two or more cases are related, so you intentionally ...
I mean descend as in languages who's original compiler/interpreter was written in C or in a language that descends from C. If you don't count assembly, the only thing that comes to my mind is B. Are there any others?
I have a CustomObject class which has the abilities like being Clickable, KeyPressable and Movable. I created interfaces: IClickable, IKeyPressable and IMovable and make different CustomObject classes to implement them. For example; public class ClickableObject: IClickable {...} public class MovableObject: IMovable {.....
I have x number of worker classes which all implement a specific interface, i have a job descriptions Each job description States the different worker classes that should execute to complete the job Am I smelling a strategy pattern here? All workers share some configuration data so I think I should have a seperate ...
C++ syntax uses almost all printable ASCII characters and some of them in several contexts. Only two unused are @ and $ characters. Why they are not used? Are they reserved for some "meta" purpose?
I need to save big data structure (Tree with specific nodes) into file efficiently. Data is always changing, so I need to rewrite whole data structure very often, so simple serialization is not good option. Which algorithms can be used to efficient saving of big data structures? I used simple serialization, but i want ...
I'm looking for a design pattern to solve the following problem: An object (let's say representing a document) can change its type dynamically during its lifetime (e.g. when it is saved with a different file extension). The object contains many virtual methods so that depending on the object type it can behave in diffe...
What is the definition of technical debt?
In my client application I have two major components: Core: wrapper that handles everything about running the actual application NetworkClient: A layer that takes care of communicating (receiving/sending packets) with the server. What I am not sure about is the way the NetworkClient should serve information to the Co...
I have a developed an Applet which works fine on Chrome/IE/FF on Windows. I am not expecting any users for Safari on Windows but there might be the odd user who may be on a Mac. As of now, I don't have a Mac to test my applet on. I was wondering how similar is the behaviour of Safari on Windows is as compared to Saf...
This is what I am doing, Creating a new Pdf document using Aspose Pdf Adding few different types pages you know introduction page, table of content pages etc... Adding some further documents to it [just created pdf]. Not sure which pattern to use. I am thinking about creating classes for different types of pages to cre...
With the danger of fragmentation due to the fork in Node, how can I make sure a "Node" project will run across both Node and its fork? The hope is that they will join together again once Joyent and the creators of io.js resolve their differences but one cannot hope that this will definitely be the case. So as a node co...
I have to save some data about users with their location. This data will only be valid for like 5-10 minutes, then it will never be used again. So I am having a simple data structure like: { user_id: 4434993283283, major: 5, minor: 33 } major and minor are used to track the position of the user. It is poss...
We have two systems, System A imports a list of sports events from system B, it only wants to import the events we will be providing live data for, the filter used to hide events that we are not providing data for is if the event has a referee assigned to it. The problem with this is that we don't know who the referee ...
I have a helper class which has a method that perform some checks against a field in a model. I have two models, ModelA and ModelB, they have some similarities but not all. One of them is they both have a field, lets say string ProductCheckField. The ProductCheckMethod returns back the Model, because of that it has cre...
The system I'm working on has a core web application where the bulk of the work is done. However, it relies on another server to handle transactional finance data. It connects to the server using a REST API. I'm trying to work only on the core web application but I keep hitting pages and function calls that rely on the...
I've consulted for a number of Fortune 500 and 100 companies all of whom have made some kind of effort at creating a "Master" data model even to the point that they'd attempt to have all applications work with a shared database (Imagine the change management issues in that world). I've seen companies throw millions of ...
Reading through the Apache Software License 2.0 appendix I am left unclear what exactly I have to do now: APPENDIX: How to apply the Apache License to your work To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifyin...
We build a highly configurable .Net Client/Server application. (Client is C#/WPF, Server is C#/WebService) There is a single code base, but each customer has its own 'profile'. The profile contains: Database/Connection string XML configuration of many aspects of the application Mail Settings (SMTP/POP3/IMAP) other app...
Recently my company setup a build server using Bamboo and a private Nuget Feed which is populated by the successful builds being deployed from the build server. There is a hierarchy of projects under heavy development setup for use in bamboo with a fairly simple, linear dependency graph. Before being setup on bamboo al...
There is something I've never understood about Smalltalk, since reading about it in a book when I was a child, tho' I have never used it "in anger". I know that it is turtles-all-the-way-down, that you can break into the program at any time, inspect the state of your objects, even change the code, and resume running. T...
Using a bytearray datatype to store a password (in memory) has an advantage over using a string datatype for a password in that a bytearray is mutable and can be overwritten with 0x00 values when the password is no longer needed for processing and until the password variable is garbage collected. It's not clear to me,...
Let's assume in our application we want to model cars. We also want to model a car repository where we store some registered cars. How should that be modeled in scala? Here comes my approach: First, I create a case class PlainCar. This is just a car how it exists in real world, with nothing special in it. Next I create...
Is there any situation, where git merge command uses frequent committing in one or both branches to prevent merge conflict (as opossed to one giant commit of week-long work followed by immidiate merge), or are those things independent?
I found this little gem waiting for me in the Windows (10/TP) bootmgr located on the first 300+- MB partition. Can anyone explain to me what it does? Is there an assembler hidden somewhere? These all look like nicely null terminated strings to me... DEBUG TRAP ^@^@** At linear address %lx ^@^@^@ TRAP %lx ^@ tr=%x cr...
So I'm making a IRC betting bot. Basically the game/bot has three states of taking-in chat. State 1 : Betting If anyone says "!bet team money" parse it and record. State 2 : Battling Take nothing in, no more !bet etc. Just watch. State 3 : Waiting/Bank Don't take bets. But take-in "!bank" and print out the users money...
Lets say I get N objects as input, and I need to rearrange them into a different data structure. This means the space complexity of my algorithm will be O(N). But what if I replace the objects with pointers to objects? I'll still have N pointers, but will it still be O(N) space complexity despite the fact that there is...
In all my experience decomposing functional requirements from the top down through a hierarchy and successfully using that hierarchy as the basis for building and implementing some pretty cool systems from the bottom up, it shames me to admit that I do not have a guaranteed method for ensuring that all the levels in th...
The book "Modern Operating systems", says The Operating System is an Extended Machine. So I wonder if an OS is a model of computaion, and whether it makes sense to say if an OS is Turing complete? Thanks.
I have a set of items, and each item in the set must be unique. Item are composed from multiple properties and each property of each item can be changed. But after each change every item in the set must still be unique. Should I simply try to change the property: int err = setOfItems.SetPropertyOfItem( item, property, ...
I am working on a Pokemon game at the moment, and am running into some design concerns. The easiest example is as follows: Each Species of Pokemon has several traits that are required before it is logically initialized. These include, but are not limited to: id: an English representation of the name (usually just the ...
I think the most common way of adding something to a collection is to use some kind of Add method that a collection provides: class Item {} var items = new List<Item>(); items.Add(new Item()); and there is actually nothing unusual about that. I wonder however why don't we do it this way: var item = new Item(); it...
I have a method, function DoThis(bool isHuman) { // Do something if(isHuman) { //call his dad } else { //its a animal - let animal resuce know } // add some blah blah code // some more blah blah code if(isHuman) { //call his mother } else { heheeee now heeeheee } // ...
I programmed a telnet server using C as programming language but I have a problem to send characters with emphases (é, è, à ...). The character encoding is different between the telnet clients (windows, linux, putty, ...). What can I do to detect the character encoding of the clients which are connected to my server ?...
I have started studying JAVA . In there, byte ch=50; ch*=2; works fine. But byte ch=50; ch=ch*2; does not. error:possible loss of precision required:byte found:int Why this do not happen in 1st case.
I have a .NET WCF web service currently running in production right now. I would say 95% of the time it works flawlessly and as intended. However; there are times when I am throwing an exception that says. CommunicationException: An unsecured or incorrectly secured fault was received from the other party. See the inne...
Imagine you are building a product recommendation algorithm for an eccommerce application which is built as a microservices architecture, this architecture having separate services for users and products. The algorithm should be exposed as a recommendation service which, given a user id, returns a list of recommended p...
Some of the CC licenses define ShareAlike term: ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. http://creativecommons.org/licenses/by-sa/3.0/deed.en What does it mean to "build upon"? If image licensed under ShareAli...
If I am correct, a page in a main memory is the smallest unit unit for transfer data between the main memory and an external storage device, such as a hard disk. A cache line of a main memory is the smallest unit for transfer data between the main memory and the cpu caches. I wonder if a page size is always or best to...
I have a set of objects, for which users manually applied tags, whatever they invented. I'd like to implement a task engine, where each task might be applied to objects from a tag. For convenience, I'd like to have an additional virtual tag "All objects" to have a task be applied to all objects regardless of tags. A si...
I remember coding file access using the Win API about 15 years ago. It was much faster than using the FileStream of my language at the time (Delphi). I spent a while today experimenting in C# under .Net 4.5, and I cannot see a real advantage to using the Win API. Most of the time the standard FileStream is faster, even...
A mobile back-end I am building should receive a larger amount of data (some sensor recordings) from an Android phone. The phone does not have much use of it so it was most efficient to store the data into plain files (SQLite can get quite slow with larger amounts). Now when we upload the data to a REST service backed ...
I've been brainstorming for a while regarding the best approach to distribute closed-source modules. I'd like to mention that I have found similar question(s) on SE sites but don't think this is exactly the same scenario. Let's say I wrote a set of well-tested PHP classes which I used as a core for multiple projects (c...
I've worked on several projects that have used agile successfully as a means of providing continuous improvement on an already mature piece of software. But I've found it's much harder to be "agile" when pre-planning something. An element of waterfall is necessary to produce initial functional specifications and a sens...
I am building a web application using AngularJs and our web server is built in Python Django Rest Framework. I would like to have the two projects separated and not coupled. In my current setup the client side web application is served as a NodeJs application while the Node server is being used only as a proxy server t...
My current company has a Jenkins/DotCi setup. Our current process for CI is when dev pushes to github, jenkins runs unit tests on all branches and reports back to us via email if the unit tests failed. If on master, we then run a deploy to a UAT environment and we will soon be activating our integration tests after a ...
In Learn SQL the Hard Way (exercise six), the author presents the following query: SELECT pet.id, pet.name, pet.age, pet.dead FROM pet, person_pet, person WHERE pet.id = person_pet.pet_id AND person_pet.person_id = person.id AND person.first_name = "Zed"; and then goes on to say that: There are ac...
Suppose a program A opens a text file A using encoding A to decode the file, and a program B opens a text file B using encoding B. When we copy some text from file B in program B to file A in program A using mouse selection, ctrl+c and then ctrl+v, I heard that the GUI of the OS (e.g. X window system in Linux, and ...
I have an application running behind a proxy, both on the same machine. Which approach is more suited regarding compression, while preserving reasonable performance. turn on compression at the application level (which happens to be in nodejs) leave it out to the proxy (which is nginx)
I would like to build a RESTful API where I need to get data from a RavenHQ-cloud-database. First of all, is this possible? The idea is to have multiple applications (xamarin-app, mvc-app, etc.) and use the API I'm building to pass the data to those applications. For example, say I have a mobile-app with one button: U...
I'm currently developing a plugin for World of Warcraft in LUA to help optimize a recently introduced part of the game, namely Garrison missions. A Warcraft Garrison (basically a player fortress) has a place where you can assign your followers to go on an mission for you. If these missions succeed, your followers get s...
Suppose you were building a system that receives data on one end and sends filtered data on the other end. The system is a chain of nodes, each receiving data from the node before and sending filtered data to the next one. You have two approaches to choose from regarding the way the nodes would be connected: A- Each no...
While looking at the Unicode properties (code point, script, block, UTF-8 and UTF-16 encoding, etc.) of some characters, I stumbled upon major differences between ` ("GRAVE ACCENT") and ´ ("ACUTE ACCENT"): Name Code point Script Block UTF-8 GRAVE ACCENT U+000060 Common Basic Latin ...
I'm building an MVC ASP.NET IMDb-like website which presents various information about movies to users, relying on 3rd party APIs to (initially) fetch movie info. The IDs representing each movie on the website are identical to IMDb's (ID tt1234567 points to the same movie on both websites). The way movie info are fetc...
In my current project I have come across the requirement to create generic classes with the same name, but different numbers of generic parameters. For example: MyClass<T1> MyClass<T1, T2> MyClass<T1, T2, T3> Given that I want all of these in the same namespace, I am confused as to how to structure and name my classe...
I'm not sure if I want to add more attributes to my models or create another model. I've coded up to the point where I need to syncdb to start using some data in the site, but I'm hesitant to do it. As long as I'm still in production for a while, I could clear the database and start fresh I suppose?
My REST implementation will return errors in JSON with next structure: { "http_response":400, "dev_message":"There is a problem", "message_for_user":"Bad request", "some_internal_error_code":12345 } I suggest to create special response model, where I can pass needed values for properties(dev_message, message_for_u...
I searched a lot, but nobody seems to have explained this nor given a proper example. I have a page like this: My team says they want to design the code such that the Title section, Menu section and Footer sections would each be kept in separate HTML files and they'd have separate JSP files for every page, where e...
Assume we have a Bounded Context for Inventory (InventoryBC) and another one for Shipments (ShipmentsBC). These 2 BCs need to communicate together. They are hosted on 2 different services on different servers with different databases. When a Shipment is made I might need to fetch some data from the Inventory BC so I th...
I have an MVC app, which has multiple views that give overviews (from different angles) on items. For now, let's just call these views View1 View2 ... ViewX They all use the same Model Collection as a basis As of now I have one controller per view (View1Controller, View2Controller, ...), and furthermore, I have ItemE...
I'm using a query object pattern (similar to this) to manage disparate queries while avoiding bloaded facades/repositories. A query object takes a number of constructor parameters, representing query arguments. The query is then passed to an IQueryHandler by the caller, into which is injected the IDataContext. The IDat...
I've been working on learning how to implement domain services and view models in my project and have noticed a suspicious trend: When obtaining data for views from my controllers, if my domain services are producing view models, I end up with one service method for each view model being requested. I'm wondering if per...
My question is based on a business model of a financial services organization that currently is supporting applications that are a hybrid mix of Classic ASP and Java, with some JSP’s already in some of the applications. Specifically, in our large application, all of the FE starts with ASP and then uses a crude reques...
I'm trying to choose a Git workflow that is most appropriate for our product. Here are the parameters: We do a few major releases a year, let's say 10 at the most We have multiple versions of our product active at the same time (some people are on v10.1, some on v11.2, etc.) We need to be able to work on multiple rele...
I've created a Delauney triangulation of a set of points. Now I want to iterate over the triangulation and remove any line segments/edges on the exterior for which the following are true: The outside edge is the hypotenuse of the triangle Call the hypotenuse the "base" and determine the "height" of the triangle. Then ...
After asking this question I found that I have a different question. What's the purpose of authenticating an API anyway? Take Twitter for instance. If you want to use this link to load some user's posts: https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name={username} Then you have to authenticate. HOWEV...
Reading on this, Misko Hevery has said “Newables can ask for other Newables in their constructor, but not for Injectables” Now it appears to me that requesting a prototype be instantiated at run-time by e.g. a Spring Container via ApplicationContext.getBean, passing it arguments to be added as constructor arguments, is...
I am playing around with Laravel and came across something in the documentation for defining 1 to 1 relationships between tables that I would like to get feedback on. The example in the docs is between a user table phone table, where each user can have one phone entry. Here is the Laravel example: class User extends El...
What would be the correct way to design a DAO which implementation is first going to be targeting a MS SQL database with a STAR model, but yet, business requirements specify the application must be flexible enough that it would be able to be migrated to a NoSQL database in the future if required. Which type of NoSQL, n...
I'm writing a command line application in Java. That app will scan a list of remote resources, do several attempts to access those resources, report failed attempts, and if succesfully accesed, perform some maintenance or diagnosis action and report the outcomes of that action. As you can imagine, there's a lot of erro...
What is the relationship between a class and an interface in objective-c? How come we declare a class using @interface instead of @class?
After reading Heroku articles, Stack Overflow questions, and the Stripe payments integration guides, the general advice is that I should should purchase an SSL certificate for my custom domain that points to my Heroku app. Can anyone offer an explanation or other resource to help me understand why I need an SSL certifi...
I'm looking to come up with a standard for how to implement a system that will automatically update software. As such, there is no actual programming (yet), but I still want to make sure my standard is robust before moving on to the stage where I build a proof-of-concept prototype. Please reference: The GitHub repo in...
We all know that code reviews are generally a good practice, but what about reviewing documentation? Many devs that I work with will put up wiki pages, javadocs, etc, but most of the time, unless someone else needs it right away the docs will go unnoticed and unreviewed. Are there any good tools or methodologies for pe...
TLDR; I'm looking for ideas on how to flag code containing file names/paths that have inconsistent capitalisation with the actual file/directory. Situation I am migrating a significant code base written in an interpreted language from a Windows/OSX dev environment and a Windows prod environment to Linux prod and dev (v...
I want to create a Microservices application, in which every microservice is responsible for its own part of the front end. At the same time, I want to create the front end in AngularJS as a Single Page Application (SPA). When a new microservice gets deployed, the web front end would automatically pick up the new front...
I've been away from hands on development work for the past couple of years and focusing more on delivery management. I'm looking to get a couple of new projects ASP.NET MVC apps off the group and I'm getting back into doing some hands on work. My question is around architectural approaches and how they might have chang...
My brother suggested that I should write a web app that lets students create and print blank maps. A blank map is a map that contains country borders, waters etc. but no text labels. The first use case is the following: User selects 'Hungary' from a list. A blank map of Hungary appears on screen. User enters a name of...
Provided that my code is fully standards compliant with no undefined behaviour, how can I best assure that it will be possible to cross-compile my software for any architecture? I had some ideas, but I don't if it's wise or possible to implement them. For example, if I could tell the compiler not to assume any paths or...
I know how to document a function: /** * Prints a greet message to the web page */ function greet() { echo "Hi!"; } Or describe the usage of a variable: /** * @type string $name The user's name */ $name = "Bas"; But I don't know how to document an interface. It requires the classes which implement the interfa...
The snippet below (in java) gives an example of my question. try { // code implementation here } } catch (Exception ex) { } Now, is that a good practice? Does it affect code performance. Is it always better to be specific with the exception you wan...
I work on a small/medium sized Java application. Over time, I've tried to ensure that the tests which I write are "good" tests, and that there's plenty of them. Hence I've been looking into various, more rigorous, testing methodologies, such as boundary value analysis, combinatorial tests, and other testing methods. Ho...
We have a lot of apps and web services (some public facing products, some internal and part of a private "backend") that are interdependent on one another. Each one of these components has 4 environments (clusters of servers/nodes serving specific purposes): Non-Production DEV - Integrated development environment whe...
I recently wrote a fairly complex C++ meta function that boils down to: template <size_t N, typename val> struct Rec { using type = typename std::conditional<N == 0, val, typename Rec<N - 1, val>::type>::type; }; Both Clang and G++ barf on this type of recession, stating that, "Template instantiat...
I'm working on a project, I have a question regarding the architecture: Say I have a many python scripts on my server and there's main.py which contains all the classes. And there's a script called copymain.py A user named alex signs up and the url of his site is stored in mariadb copymain.py checks if a user has sign...
I'm writing a webapp for chess which, for a given move and a database of games, shows all the moves that follow from that move. Pretty much what this website has already done: http://www.chessgames.com/perl/explorer The database will have a table of "moves" which have a link to the previous move in the sequence. Findin...
I was working with a team on a web-based software. We have written ~70-80 Selenium test for the product. Mainly happy-path tests with some regression ones for bugs reported by users. It was the first time when our company did automatic UI end-to-end testing and it seems quite helpful. We have some success stories as we...
I spent a few months working on an iOS app of mine (in Swift) before realizing it was really a bunch of MVCs (Massive View Controllers). I want to start fresh and build something modular, scalable, and maintainable, but finding any clear information on good ways to do this is more difficult than I thought. I am new to ...
Sometimes my project has multiple pull requests. I don't know what is the proper process to handle it. Currently what I do is Review each pull request. check code looks ok, and all comments were treated check if travis-ci passed and if github can auto-merge the request if all of the above is correct, I accept the...
My team of developers are currently working at a client who has required us to move away from SVN and begin using their native workflow program. (Source tree by Atlassian). We are data warehouse developers and utilise primarily the Microsoft SQL stack for development. The stack is commonly: SQL Server Analysis Servic...
I have a 3D array with booleans and I need to check if there are "lines" that all contain true or false. With lines I mean horizontally, vertically and diagonally within the array. However I only need to check this when an element changes and I know the location of the changed element. The array is always equal on all ...
From http://en.wikipedia.org/wiki/Extension_(semantics)#Computer_science In computer science, some database textbooks use the term 'intension' to refer to the schema of a database, and 'extension' to refer to particular instances of a database. does a "particular instance of a database" mean a database, or a tuple ...
Say someone calls a web service on a server, the relevant data is being retrieved in batches and the message is being streamed to the client. In the middle of the message some kind of exception is encountered. My current implementation sort of just stops streaming the (in this case soap) message and starts streaming an...
For my project I have a hashtable with 1M buckets (sometimes more). Each bucket contains lots of values and they are stored sorted in a dynamic array. I am looking for easy enough way to store all values in a file (printf will do as well), but in sorted way. Is there a way to do so in less N*N complexity (e.g. merging...
This is sort of a follow up to this question about NLG research directions in the linguistics field. How do personal assistant tools such as Siri, Google Now, or Cortana perform Natural Language Generation (NLG)? Specifically, the sentence text generation part. I am not interested in the text-to-speech part, just the t...
This is a question of model design, and hopefully some architecture nerds have strong opinions on this. I've been developing one that I will post in an answer. Typically, in every codebase I've ever seen, if your model has an integer id, it is typed as an int and if it has a guid id it is a Guid. Is this really correct...
I'm using the MVC architecture Laravel 4.2 to create a relatively complex web application. This application consists of a website which is very heavily based on whether an event has occurred or will occur. i.e. if an event is in the future, I will be displaying a countdown, whereas if it is in the past, I will be displ...
In a closed source proprietary web application, if I use an AGPL product in a sub-domain or in an iframe do I have to open-source my project? If answer is no, is it possible that both applications can share the same database?
I have two methods in the same helper class one that creates an image (createImage) and one that compares two images (compareImages). Image createImage(Data data); Boolean compareImages(Image from, Image to); I want to check the return of createImage against an existing image. To do this I need a method exactly like ...
I'm preparing for an exam on which there will be problems solvable by DP, greedy algorithms. And one of the problem is - given a string containing parentheses in no particular order return a minimum number of "rotations" needed to make a valid expression, for example ())) is not a valid expression but you can "rotate" ...