instruction
stringlengths
34
36.1k
I was assigned to maintain an application written some time ago by more skilled developers. I came across this piece of code: public Configuration retrieveUserMailConfiguration(Long id) throws MailException { try { return translate(mailManagementService.retrieveUserMailConfiguration(id)); } ...
I have a piece of code that I need to test, which is layered in three parts: Web API Controller Persistence/Logic Layer System calls for persistence It's the basic GET/POST/PUT/DELETE call system. For instance, in the controller I have the GetAll method which calls into a Get in the second layer, which in turn calls ...
Most of the examples i've see when watching anything on dependency management hit what i consider to be the holy grail in that the only dependencies on classes are interfaces that the IOC container can inject in. Of course most of the examples have to be trivial because of time constraints the presenter is under. Thats...
Is there an industry standard in how many times a scenario is tested before it is considered passed? Is it common to test a given scenario using multiple different records? Here is the issue: A development project is now in the SIT phase and the developers' plan is to test each scenario once unless it fails. There i...
I heard that SQL is Turing complete language (for example: https://stackoverflow.com/a/7580013/2604170) I am just curious if would be possible to create independent web framework like Ruby on rails or Flask (Python) in pure SQL (SQL would replace python or ruby or java for example) It's just idea, but I think it would ...
My domain aggregate is struggling with simple business logic so I feel like I have modeled it incorrectly. The architecture I have right now uses domain driven design with event sourcing. The domain aggregate produces events which get digested by subscribers. Eventually the event queue will be empty and the view store ...
I have a project where the only difference are the templates. The question is how should I manage this with git now? At the moment I have 3 different git Repos, but it's hard to maintain all 3 of them. What would be a good solution for this problem? 1 Repo for the Codebase and 3 for the different templates(submodules/s...
I'm new to Docker and feeling my way around. My plan is to build a typical web app using Nginx+Rails+Postgress, all of which will be in the one container. I'm not (currently) doing anything complex like linking images. I'm a lone developer, and my build process thus far is: Edit Dockerfile docker build Fix bugs, and i...
I'm trying to model a multi-dimensional point class in C#. I have about eight different types of points, and there may be more in the future. Right now, I have a superclass (PointBase) that holds all the common behaviors and data. This data includes only simple properties like doubles, strings, enums, and DateTimes (th...
It's a pretty naive question to ask but I got this doubt while programming for Android. I use to initialize my new strings like String a=null, so in my code there remains a probability to get NullPointerException if I forget to initialize the variable before accessing it but what about the other case. Also which one sh...
In Haskell, I can use the type a -> Maybe b to model a function that either returns a value of type b, or returns nothing (it fails). If I have types a1, ..., a(n+1) and functions f1, ..., fn, with fi :: ai -> Maybe a(i+1) for all i, 1 <= i <= n, I can chain the functions by using the >>= operator of the Maybe monad an...
I'm writing acceptance tests for a web application using Behat/Mink. I want to know best practice for testing strings in the GUI. For example: say I want to test that a link exists on the homepage to the login screen, by looking for a link with a text, such as "Log In". I want to make it robust; at the moment, for ex...
I'm working on an opensource application that processes JSON in C, because I would like to make it easier for people to help me in the project and because JSON is so close to JS. I want to embed a JS engine and compile the JS into the software. The reason I've chosen C for this particular program is because of C's spee...
So, my understanding is that the Kernel could receive TCP at any time, and that generally a C program asks the Kernel synchronously/asynchronously if it has data available. Would it be possible for a callback to happen in the Kernel once a certain amount of data has arrived on a socket? This may be best asked in a sepa...
I'm implementing a type of Repository for a framework/library that has (roughly) the following: public interface FooRepository { boolean contains(String id); Foo fetch(String id); void commit(Foo foo): } We can implement it several different ways, depending on what storage medium we're using; for exampl...
In CSS you declare a background-image by wrapping it inside a url('') ... is there an example when you don't need do this and if not why does it even exist? Even when you're using base64 you still wrap it in a url and I can't seem to find a reasoning for why this is the case. You don't wrap background colour around add...
I'm creating a commercial web-app and to avoid compatibility issues between operating systems and browser I want to pack a portable chromium alongside my software and to use it to run the app. GPL2 states: "b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from t...
I'm working on a server implementation for a large game with many gametypes. There are several kinds of interactable entities: players, monsters, objects, vehicles. All entities share the same base class (which is Cython): cdef class Entity: cdef public int id cdef public double x,y,z,yaw,pitch,speed def _...
I have the following code: def __init__(self, vocable_file_path, xsd_file_path, word_list_file_path): self.vocable_file_path = vocable_file_path self.xsd_file_path = xsd_file_path self.word_list_file_path = word_list_file_path def add_values_to_attribute_of_vocables (self, attribute_name, attribute_value,...
Should they be written same way as human workflows, first person "I have entered..." style language etc.? Is the user effectively a gender-less "AI"?
I have an Either type e.g. Either[A, B] but I want an Either[X, Y] by using two functions A => X and B => Y. I can do that with fold: val myEither: Either[A, B] = ... myEither.fold( a => Left(createNewX()), b => Right(createNewY()) ) But that seems redundant to me as I have to repeat the Left and Right. I rather w...
I'm a rails developer, and have noticed that while defining validations I find myself confused about the scope I'm trying to cover. For example, I have basic cases where a field of data (ex: name, email, etc) needs to be present, or the correct size, format, etc. These cases are easily handled by existing Rails validat...
Imagine the following situation. Two devices (master and slave) communicate with each other using any serial protocol like Modbus or HDLC or custom-made one. Master device sends a request to the slave device. Slave receives the request, but it is too busy to answer right now, so the master sends a second request after ...
I receive several CSV files each quarter to process through an SSIS package, and the formatting is inconsistent. This quarter, I encountered what I term optional text qualifiers--text qualifer of double quote (") used at times, but not always. We appear not to have any sway over the people who provide this data to conv...
We are looking to expand our e-commerce store to allow customers in countries outside of the United States to shop and see prices specific to their region. The prices are not just straight markups from the US prices; we build the cost to ship the product, any tariffs / export fees, etc. We are looking to keep our pay...
I currently am working on a project that involves several discrete components that have some common functionality, and I am in need of some advice. Right now I have a central component responsible for dispatching requests to several components that translate the requests to particular formats for particular data source...
Is there a better algorithm to distribute values from one source to X destinations minimizing their difference? I have some source integer. I need to know how much of that value I need to distribute among some other values the proportion of that source to be distributed among other ordered integers in order to align ma...
As I'm sure anyone reading this knows, the default behavior for npm is to install sub-dependencies within their respective sub-dependency directories themselves (in a new node_modules directory). The default behavior for composer, on the other hand, simply puts all dependencies, including sub-dependencies, into a singl...
I'm writing a Gateway class that extracts information from a HTML document. One of the responsibilities of the class is to traverse a table in the document and extract data from its rows. I'm trying to decide how to best represent a row, and I've come up with two solutions (in semi-pseudo code). I could represent each ...
Customizing Chromium includes fixing homepage, removing address bar, .etc. Is it possible to modify the source code or using some compiling options to achieve these goals?
I am currently reading the following tutorial and have gotten up through here http://docs.oracle.com/javase/tutorial/java/concepts/interface.html Maybe I should not be thinking about this question now because the tutorial hasn't brought it up, but I have a question of good practice. According to the tutorial up to thi...
I have just graduated not long ago and started to work in a startup company for almost a year. I have introduced git to my current company and they are now happy to use it for version control. I feel that my boss and the company is open to new stuff. Recently I have heard about the idea of code review and want to give ...
The task is to make a migrator from Old DB to New DB using OOP Single Responsibility Principle. My problem is how can I make this without making the controller a God Class or breaking the single responsibility. I've thought of two methods of implementing this Iterate through each property row and cascading to Subdivi...
We are testing a library under C++11 (i.e., -std=c++11). The library uses auto_ptr and this pattern: Foo* GetFoo() { autoptr<Foo> ptr(new Foo); // Initialize Foo ptr->Initialize(...); // Now configure remaining attributes ptr->SomeSetting(...); return ptr.release(); } C++11 deprecated auto_p...
I am trying to write an utility which traverses through a list of files and searches for a string in each file. On finding the string in a file, I will add it to a list and display the list. Which design pattern should I use for the same?
In an effort to understand Generics in Java (and how to use them), I am trying to implement a list structure using them but have hit a wall. Scenario: Suppose there is some classes (we'll call them ClassA, ClassB, and ClassC) which all extend ClassBase. ClassBase is abstract, and simply contains an ID code with appropr...
I've been using JIRA for few months -we are following traditional development methods (no agile/scrum). One of the things that I cannot decide, is when should we create separate projects in JIRA, and when should we add issues to the current projects and not creating new projects. The nature of the projects we work on ...
I've got big and hairy app with sqlite via dbi (from .c) as a backend - plenty of select/insert/update/delete queries. From looking through documentation I did not found a way to log all the queries issued towards sqlite. I mean of course I could wrap every call to dbi_conn_queryf() into function which does the logging...
Is there any mechanism or best practise for finding aggregates by different property than aggregate ID? I'll try to explain my question on example. There is Cart aggregate (event-sourced) and Product aggregate. There is a rule that when bussiness cancels sale of Product, it must "disappear" from every Cart aggregate. H...
I am using jQuery, angular, bootstrap, along with some custom js files. Currently, I have everything bundled into one script. Since, jQuery, angular, and bootstrap are available via CDN, is it better to just grab them from the CDN or should I keep those bundled with my scripts?
Our logger data has gotten a bit out of hand, so I am trying to find ways to trim out unnecessary log information. What I've found is that the programmer who implemented the logs (no longer working with us) used a lot of user input to log application activity. I was under the impression that logging user data was a ...
I have a base class with a fair amount of "meta programming" to give it the flexibility/abstraction it needs to be rather generic. I do have a lot of subclasses using the common methods in the base class, and I have behavior oriented unit tests covering all of the cases in each subclass. Is it ok to skip testing the ba...
I have a requirement to build a 'base' profile library (in C# - NET 4.5.2) for various different internal (technical) consumers. This profile consists of metadata fields that would be shared by a wide-variety of different profile implementations. The metadata for these different profiles is stored in a single location ...
This SDK have an interface like this: public interface Contract { void update(..); void action(..); void delete(..); } Now, we need to change it to something like this: public interface Contract { String update(..); String action(..); String delete(..); } The interface is implemented int...
I need to implement a mailbox monitor system as a web service. I have follow classes: MailboxMonitor: Contains information such as username, password, pulling interval etc. MailboxMonitorRepository: Retrieve and store MailboxMonitor from database. ExternalService: Retrive and process emails based on the given MailboxMo...
Scenario To deliver instant notifications to the client, I'm sending an AJAX request to a PHP page that checks if there are new notifications: if there are, it outputs them, otherwise it sleeps for 10 seconds before trying again, so it has a basic structure similar to the following one. <?php $max_attempts = 10000; for...
Lately I've noticed a trend amongst some website homepages to present information in a vertical fashion, forcing the user to scroll down to continue reading the content. As you scroll down, a state transition occurs that has the feeling of an AJAX request and a new page/frame is presented to you with new content. I cal...
In similar fashion to this bit of node.js, I'm interested in streaming the ongoing output of a text log file via ASP.NET MVC. I'm having trouble even thinking how I would implement this using the APIs available via the .NET framework. At least, the streaming of new file content as it is written part. if I were able to...
I'm writing a small library that helps you hydrate JSON data into objects. Given this JSON example: { "date": "1970-01-01 00:00:00", "foobar": "baz", "user": { "name": "foobar", "id": 2 } } And the following library ruleset: Hydrator hydrator = new Hydrator hydrator.add("date", DateTime...
I had a Service layer in my app and, for a while, there's just one class for API calls Current Scenario MyAPI Class authenticateApp() authenticateUser() Looking in the future, that class will be so huge that will be difficult to maintain it. Even if I group calls by the same module (user authenticate, user profile, e...
What do those #-signs mean? For example, data Word = W# Word# deriving (Eq, Ord) I tried to google it but I found nothing.
The LGPL seems to stipulate that I have to distribute my app in a way that the LGPLed code can be replaced. Xamarin keeps saying that to distribute a mac app in the store, I need to use Xamarin.Mac and buy a license. Now, if I have a closed source app and I distribute a .app bundle where the Mono runtime is present as ...
I have been researching Interpreters/Compilers, then I stumbled across JIT-Compilation - specifically Google Chrome's V8 Javascript Engine. My questions are - How can it be faster than standard Interpretation? Why wasn't JIT-Compilation used in the first place? My Current Understanding Every Javascript Program st...
Scenario: I have a loop that iterates over an Array of COM objects and does some work using them. My fear, working with COM objects, is that some exception will creep up (possibly on another user's environment) and cause the loop to break mid-way through processing these objects. So, let's say (hypothetically) an excep...
I'm working on a medium size C++ project (will probably end up around 50k lines) and I have to provide an interactive terminal interface. The program produces scientific data as an output and the interactive interface is to let a researcher tweak a visual representation of what's going to be calculated before actually ...
This is not something I would ever normally do, but I have a situation where some existing legacy code is being reused in a new application. The code is shared and needs to be used by both the legacy and new application. The legacy application is a reporting application and errors are reported as messages no differentl...
Question perhaps slightly left of field - but I'm curious as to the logic behind why Java's BigInteger/BigDecimal classes feel the need to define a constant of TEN? Example taken from java.math.BigInteger: /** * The BigInteger constant zero. * * @since 1.2 */ public static final BigInteger ZERO = new BigInteger(n...
What's the advantage of having a generic base class and a derived class having itself as the generic parameter on the base class. e.g. public abstract class MyBase<T> {} public MyDerived : MyBase<MyDerived> {}
For sequential data models like LinkedList, search algorithms like linear-search and binary-search are well known. Are their any other search algorithms apart from these two, that work on sequential data models like LinkedList? Note: As far as representation is concerned tree can also be a sequential data model(using p...
I'm using the form object pattern to handle data normalization and validation in my app. It's working well for simple cases, but some of my form objects are composites (or roll-ups) of multiple other form objects, in order to build out the proper associations, and validating them has become a nightmare. For example, I ...
Lets say you are building an application that staticly links against libraries that you provide it. Where should you store these static libraries? Should you make a directory in the parent directory of your application called "libs" or "dependencies" and store it there? Is there a practice for doing this?
I have asked a question here about js, regex, quantifiers and global search. I've understood finally how this works, but, let's take a concrete example and then I`ll write my question. Based on the same example var str = 'ddd'; var r = /d*/g; console.log(str.match(r)) it outputs this array: ["ddd", ""] I understand t...
Let's say that we have some sort of "schema" for a rest resource, something like (pseudocode): ExampleResource: field1 = field(validate=is_string()) field2 = field(validate=is_int()) field3 = field(validate=is_string(max_length(200)) creator_id = field(validate=is_int()) Depending on the permissio...
I'm conceptually designing a website / application and trying to come up with the correct separation of concerns. The basic technologies I'm settling on are: MySQL, PHP (Laravel), HTML/JS (jQuery). It's been a few years since I've written PHP, and since then I've gotten very used to MVC and MVVM approaches. I would lik...
I am a new teacher at polytechnic where we teach web development and basic software programming. For years, the institution where I teach have taught C as their introductory programming language to people who are assumed to have no knowledge in programming. I am investigating if there is a better option, and was thinki...
Is it proper to use below syntax for try catch?? try { int a; int b; int c=a+b; } catch (exception ex) { //Nothing here }
This might be only a question of definition, but maybe there's a consensus? Given the situation, software Foobar Plus is under construction, we're not working on an update, but on the first release of it. Now, a specific feature(A) was implemented; Feature(A) caused a unwanted behavior in feature(B). It has no influe...
I'm designing a language and was wondering how to incorporate C++-like references with regards to their place in the type system. I think they're useful for operations like indexing and dereferencing (v[i] returns a reference that can be assigned to, *pointer_type<a> returns a reference to an a that behaves like an a)....
This may be tedious, but I would love to know which is a more efficient way of programming. The result may only be slightly better or slightly worse, but I am still interested in which is 'better'. Say I want to create an array of String objects based on the amount of columns I received from an SQL query and then go ah...
I am both the sole developer for a relatively small company and someone who enjoys programming as a hobby. Recently, for one of my personal projects, I started making a framework for a RESTful API and NoSQL integration that I enjoyed programming at home. Near the same time, my work assigned me to begin a project for in...
I am experimenting with hierarchical task planning (in python) and I would like to have functions which return lists of tasks. I need to differentiate between alternative paths and sequential tasks. My current approach is to return a list of lists of tasks, e.g.: def travel(): return [ [call_yellow_cab, ride_yellow...
I'm creating a server in Java (although this question is language agnostic) that will do the following: Pull a set of "leads" from a database every 10 minutes For all leads with a certain marker, use a different database to get additional information For every lead that actually has relevant data in database #2, combi...
I have two web applications, say Application_1 and Application_2. Application_2 has a database table named table_2, which changes infrequently, and needs to be accessed by Application_1. Does it make sense to create a table_2 table in Application_1 and update it with an ETL task? A straightforward solution would be ex...
I am having a difficult time determining where my IO logic should reside within my application. In this application there are multiple IO devices both USB and serial. I currently have the idea to separate the communication with the devices from their control forms and control threads; ie click a button on a form and th...
One of my team mates and I just grabbed separate bug tickets, assigned them separately to ourselves, but the tickets were duplicates! What is the best way to resolve duplicate tickets? Is this generally done by QA resources? I've worked at a couple places where non-tech people say it interrupts there "flow", but it is ...
I'm reading a guide for back-propagation of a neural net, and it gives the error function as: Next work out the error for neuron B. The error is What you want – What you actually get, in other words: ErrorB = OutputB (1-OutputB)(TargetB – OutputB) But then, underneath that it says: The “Output(1-Output)” term is nec...
I am writing a game in which I have a Java server/client system set up. Everything is working great, but I reached a slight problem. I have set up a basic health system, and a GUI to go with it (for example, health bars over everyone's head), but the problem happens when I want to give every player a separate GUI (e.g...
I have an Android application that associates bluetooth beacons with data that is retrieved from a server via RESTful calls. Once the app is launched, we have a page with a table that is being filled by data from the Bluetooth LE scanner. My issue is this: I have three data models: The BluetoothAdvertisementModel, whi...
Let's say I have a sequence of items of unknown length, n. I want to randomize the order of this sequence without having to go through the entire sequence. Are there any algorithms that can do this? Example: I have 10 items in my sequence: A B C D E F G H I J (though I don't know that I have 10). At the end of my rand...
I have a few methods which are stateless: loginWithEmail: password: completion: signUpWithEmail: password: completion: resetPasswordForUsername: completion: Currently what I do is I create a class which holds these stateless methods: @interface KGAccountService : NSObject + (void)//method1 + (void)//method2 + (void)/...
I am writing a client which has support of 'offline mode'. When offline records can be stored locally. When we go online we want to be able to synchronize these records with the remote API. I want to be able to keep track of some state like the progress of the sync, whether we're syncing or not and other things like t...
For context I am fairly new to programming after returning back to it after programming a number of years ago... I was reading Bjarne's intro programming with C++ and was wondering if alphabetical string characters are assigned numerical values for the purpose of comparison. For instance in this example from the book B...
I've just finished Effective Java and I loved it. I'm trying to refactor one of my programs to take advantage of what I've learned, and I have a lot of questions regarding immutability. My program is largely built around a model class representing a reminder, which is stored in a content provider. This article suggests...
I know there are hundreds of questions about this on here. I've probably read fifty different questions, blog posts and textbooks. The problem is I've gotten about 75 different answers. I have seen all of the following described as some type of factory, and I can't follow the muddled terminology, and get confused on th...
When you want to update, migrate or deploy-new-version of a large and/or critical system, absolutely, you can't shutdown the system and do your job, then start it!!! I want to know what's the requirements of designing a system that can be available during update,...? what's the compatibility issues? How clients should ...
I've been reading up on microservices architecture, which gained a lot of recognition in recent years. As a big fan of UNIX philosophy, I find it very clean and sensible. However, exisiting publications as well as libraries/frameworks seem to treat microservices as solution to "big data", "web scale" and similar buzzwo...
I have custom MVC framework in PHP and my controller file has about 5000 lines. The question is, is it a big concept flaw? It is structured code with kiss method and quite maintainable. Are there any rules that specify how large the controller should be? And offcourse could it have some bad influence on web performance...
I’m having some questions regarding improvement of code structure and maintainability, especially regarding SOLID. These questions are specifically for this project, so I would be happy if this doesn’t end up as a duplicate topic post (I am aware there are a lot of posts regarding this topic). The main question is, if ...
I'm new to Entity Framework, and currently developing an MVC 5 application with Code-First Entity Framework 6.1.2. I need to write custom reports. Instead of writing complex linq, I can write a couple quick Stored Proc's and write the results to CSV. Can I call these procs with EF? or would I just be better off using A...
I recently started to work in a java enterprise project (~200 people) that uses a SWT rich client. In many cases I've found business rules not being validated in server side, because the widgets that trigger such actions are disabled in the SWT client using the business rules. This is a well known question of validatio...
I've just started the project and I have this sort of parts in my solution MyApp.Web MVC Web Application MyApp.Data Class Library MyApp.Domain Class Library MyApp.Service Class Library MyApp.Utility Class Library So I wanted to have webapi in my application, and my question is where should I put the webapi codes. in ...
Overview A central web application to supports other web applications(A) for user and its role/permission management. Applications (A) call the central application via API to get the user roles/permissions. 1) Application(A) can have resources. 2) Resources can have permissions. 3) User can have access to resource/perm...
I am currently writing a web application in ASP.NET MVC, so far it is mostly a simple CRUD web app. The database is hosted on the cloud and I am using Entity Framework to interact with it. I know that further in the development cycle we will have to make a mobile application (iOS with swift) which will interact with th...
Our company has developed a PHP(CakePHP) "Cloud" application that is running on our servers, now we have some customers that would like to use our service and make integrations to their local systems. The local systems are behind a firewall that won't be opened for us to access them from the "Cloud", therefore we need ...
I'm trying to learn more about the current orthodoxy with respect to ASP.NET MVC application design, and I stumbled upon something that confuses me, relating to the choice among database design strategy (code first, model first...). This is the author's claim (paraphrasing somewhat): The code first approach does not a...
Assume you have a class. It can really be any class that defines a domain concept like an employee, a product on an e-commerce site, or a car. One of those examples that are oldies but goodies. According to the SRP, that object should be responsible all of "its" things. I would consider an employee taking a lunch, a pr...
I have an app that uses an API server and I do not want to have anything other than it to be able to use that API. I know this isn't totally possible, but I want to do what I can. I don't think my current method of achieving this is the greatest and I'd like to scrap it and start over fresh. Here's how it works: The a...
I have a basic understanding of what a "stack" and "heap" are. You use a stack to store items in memory that should be read and/or removed in a last-in-first-read/removed manner. To steal another example from someone else's Website, you use it to perform arithmetic operations involving PEMDAS. You also use a stack to s...
This is a general design question, but I'm focusing on C# and .NET because those are the languages I'm working with right now. Should I create my own, new exception classes, or co-opt existing framework exceptions for slightly different purposes? For example, I'm finding myself needing an exception that indicates a me...
I have a C# program (could be any programming language) that saves data to a file on a memory (hard disk, USB drive, etc.). The program uses this data for monitoring its operation time, but it could be any purpose. When the program is started, it reads the data from the file so it knows how long it has been operating b...