instruction
stringlengths
34
36.1k
We have an Angular JS app for which we use Bootstrap CSS. We are currently using pure Bootstrap with the default CSS files. However, we need to style the app in my companies corporate design sooner or later. What's the best/recommended way to do this? We already thought of the following possibilities: 1 # Simply overwr...
Many coverage tools evaluate an entire project, including unit test code itself. In VS 2013, the Analyze Code Coverage/All Tests option includes test code in its report. OpenCover does so as well I believe. In Eclipse, a Maven project with the typical src/main/java and src/test/java setup, EclEmma will report coverage ...
One of the advantages of open-source programs is that they can be ported easily to any platform simply by recompiling. Qt is also a cross-platform toolkit that can work on several platforms simply by recompiling, and so applications can be ported between Windows, Mac, Linux, and other desktop OS's. Is there any possibi...
So in PHP, there's PDO to fetch things from a database. Now I see a bunch of $stmt->rowCount() calls in the code I'm working with. Why not just fetch the result array and throw a PHP count() over the result to fetch the row count? Wouldn't this make PDO's rowCount() obsolete?
I am learning OpenGL/C++ by following a tutorial series on in2gpu. I set up my Project just like the autor did. It is an Empty Visual C++ Project. Inside the project I linked glew and freeglut, the according files are inside a Dependencies folder which I copied into the project folder. Everything works like a charm so ...
I'm not sure if I am getting this right. In order to observe proper SOLID principles, am I forbidden to inherit from concrete classes? Does that mean that every concrete class that I have more or less be sealed (or at least considered to be sealed)? This is confusing for me because I encountered this code from our rep...
I'm creating a Rest API using Spring Boot and I am using Hibernate Validation to validate request inputs. But I also need other kinds of validation, for example when update data needs to checked, if the company id doesn't exist I want to throw a custom exception. Should this validation be located at the service layer o...
One of the things I love about Go is how they encourage passing errors as return values, but when it comes to logging what is the most maintainable solution: passing the error as far back down the execution stack as possible and logging everything there, or logging it in the function it occurred there and then? So the ...
My team is currently facing a problem that we don't know how to tackle. Some technical details: we use Java 8, Hibernate, Spring, MySQL, and AngularJS for the front-end. We need to do pagination on a combined set of local and remote data. The approach we are taking is the following: Query our local database since we s...
For an interface that can be used symetrically like for example interface **ipc** send() receive() Both components receive and send. How do I represent this in UML? Currently I am doing this: Is this how it's done in a component diagram? If not, what's a better approach? (Please ignore the ports, the real comp...
I have written some projects. I try to annotate or comment all possible (hard to say if correctly toward clean explaining). I would like to write documentation for it, but I have problem with examples. It is not problem to write in annotation above each function (where it is really needed) examples of all possible usin...
If Strings are immutable in Java, why is the output of this code 2GB, instead of 1GB? class Laptop { String memory = "1GB"; } class Workshop { public static void main(String args[]) { Laptop life = new Laptop(); repair(life); System.out.println(life.memory); } public static void re...
I'm writing a simple whitebox unit testing suite for a project I'm working on in C. The project is broken into modules (each has a .c file with an associated .h file), and all modules are compiled together into one .so file. Obviously, the .h file for each module contains function prototypes for any function that is me...
Having chaining implemented on beans is very handy: no need for overloading constructors, mega constructors, factories, and gives you increased readability. I can't think of any downsides, unless you want your object to be immutable, in which case it would not have any setters anyway. So is there a reason why this isn'...
Consider this bit of code : private Norf foo(Baz baz) { // ... // Logic on baz // ... if (baz.color == Baz.BLUE) { // Do this thing } // ... // More logic // ... return norf; } Assume that the content of the if statement is at the wrong level of abstraction for foo and th...
Background I'm a technical lead on a small team of three developers who work at a community college. Because of the nature of our environment, our projects are typically related (since the core set of data we use is relatively small), but all of our work is done in separate, independent C# solutions with ASP.NET front-...
I've been thinking about creating custom types for identifiers like this: public enum CustomerId : int { /* intentionally empty */ } public enum OrderId : int { } public enum ProductId : int { } My primary motivation for this is to prevent the kind of bug where you accidentally pass an orderItemId to a function that w...
Actual architecture I have an app where a model is attached to every activity. The model ask a repository for information that can come from server or local db depending on many factors. When it asks server for information it creates a petition encapsulated under an object that goes to a webService Manager that process...
I have a Java project whose architecture is quite component-oriented, and I am wondering if this is a common way to organize code which rules/patterns are used, if there is a name for this coding style. Component packages src/namespace/component1 src/namespace/component1/error src/namespace/component1/impl src/nam...
Usually you put your license into a single file called COPYING or LICENSE. However there may be reasons you do not want to do this - let's not discuss them - and therefore you look for alternative ways. So what about putting the license into the issue tracker? An advantage may be that you can clearly see who did this (...
If the testing phase is over 5 months long do the developers help the testers execute scripts? I don't know how it's done in a waterfall lifecycle where the phases are usually quite long.
My company has a series of WinForms applications that pretty crudely provides authentication by checking usernames and passwords directly against the database (with a little hashing). I have a fair amount of experience with ASP.NET WebAPI projects, and the single-sign-on experience you get out of the box. By that I mea...
When creating a variable foo, Python lets you just write foo = bar. However many languages, like C# or JavaScript, require additional syntax like var foo = bar or foo := bar to signal the same thing. Is there a reason why C#/JS require explicitly differentiating a declaration from assignment? I can imagine that a parse...
I should probably open this by saying I do mostly Web applications at work, which obviously have some major differences from typical desktop stuff. I had a small Windows Forms program I'd made for myself. As I went to update it and add some stuff in I found that the program and presentation logic was too tightly coupl...
I've recently had an argument with a colleague about using getters (without setters) in a view-model classes used by XAML. Example: public string FullName { get { return $"{FirstName} {LastName}"; } } //call OnPropertyChanged("FullName") when setting FirstName or LastName His argument was that you shoul...
#include <iostream> class Base { private: int b_value; public: void my_func() {std::cout << "This is Base's non-virutal my_func()" << std::endl; } virtual void my_Vfunc() {std::cout << "This is Base's virutal my_Vfunc()" << std::endl;} }; //----------------------------// class Derived: public Base {...
I'm about to build a SQL table where I want to store currency orders. That means that I need to store how much I paid for a certain quantity, and the ratio between both quantities. So for example: +-------------+--------------+-------+ | Quantity US | Quantity EUR | Ratio | +-------------+--------------+-------+ | ...
Take the two code examples: if(optional.isPresent()) { //do your thing } if(variable != null) { //do your thing } As far as I can tell the most obvious difference is that the Optional requires creating an additional object. However, many people have started rapidly adopting Optionals. What is the advantage of...
I have ~30 resources each having ~10 attributes. I want to store some information about each attribute. Ex: its multiplicity, it RW (Read/Write), RO (Read only), longName, shortname. So I was thinking of storing it in a Enum like: public enum Attributes { U_RESOURCETYPE(true, "RW", "resourceType", "rt"), U_RES...
Gradle is such an interesting build tool that it prompted me to look at Spock and JUnit -- which I've never done before. What is the basic workflow with TDD? My approach has been to do frequent builds, slightly less frequent clean builds, and to run the application as much as possible. Certainly, there are entire boo...
I am working on Qt/QML/MySQL app and I want to achieve maximum customization of software; therefore I've packed app's settings into SQLite3 database file. I have several SQLite3 scripts hardcoded into app, but my question is is it better to have these scripts embedded into code itself or should I have physically SQLite...
I'm developing an API that performs bulk update of a large number of items in a single call. This code will consist of a REST endpoint and the internal library code that it calls. There are a few reasons why the update of a specific item may fail (e.g., the item has been deleted). The question I'm debating is how to re...
My application is a generic enterprise application which can be deployed on any application server running on any OS. I don't know how/where to configure my application, except for the database information which are stored in the application server as datasource. While it's easy to do, I could use the database as a con...
I'm a junior programmer near to my 6 month probation, following my initial career changing 3 month assignment in which I added TDD tests and wondering whether I should add tests to my current work. The senior programmer says I can if I want but he hasn't, but he does wants me to document the system whilst I'm learning ...
I and one guy have been discussing potential solution of a problem on an unrelated board, regarding the typical getter/setter hate, ie. using getters/setters leads to procedural programming. I presented the attached solution as a representation of encapsulation and the TellDontAsk principles, which he said was not OO e...
I am looking for a pseudo code logic that would find n equally sized areas in a given polygon. No space should be between or outside the matched areas. First valid match of areas should be returned. Assuming following polygon [2,2, 3,1, 5,1, 5,4, 4,5, 2,3] as an input: ...and 3 as a parameter a valid output could be [...
I am launching a iPhone App. Do I need two separate domain names for the app and the landing page website or can I use the same name for both. The website will solely be used to advertise the app information.
I started questioning what I know, or thought that I know, after this question: Array.fill differs from literal 2D definition on assignment A JavaScript question, defining an array with predefined length and filling it with values, and then changing one of the values within the second dimension. Mutability, in this app...
We're developing an application whose data domain (or at least 90% of it) can be modeled effectively using a relational database. We've been using PostgreSQL since the beginning and have had no problems whatsoever. However, now the need arises to store relations (friendships) between users, much like Facebook or Snapch...
Most OO guides say not to store things in instance variables if they can be easily calculated, because the state might become inconsistent, and there is more code to maintain. I am trying to come up with a general guideline of how to decide this issue. For example, if I have a simple object like Rectangle, I could sto...
Came across this open source project called fruit. In the documentation are some diagrams of the code. Here is an example from the tutorial page: Is there a standard for this type of diagram or is it just a custom one?
Let's say I have a sort method inside of my class and another class that has no relationship with that class needs the same method. Instead of writing that method twice and breaking the do not repeat yourself principle of OOP, I decide to make a class like it was an invention to solve that method calling it a Sorter. I...
Hello StackExchange community! This is my first post and appreciate any help anyone can offer. I'm new to Java, and I'm sure this issue is simply due to my misunderstanding of the fundamentals. I have a JavaFX (Java 8) window with a TreeView filled with TreeItems containing a Product object. This object has many fields...
I am a sole developer working for an organisation that has no testing strategy. I am trying to integrate a crime system developed by a vendor with an external application I developed. The external application allows an end user to send an instruction to the crime system to delete the crime. The crime system was develo...
This is an iOS app but I will try to make it as general as possible because I think a wide audience could have good feedback. I have a application I am making for iOS. It has 4 main tabs in a tab bar controller. There is three main model objects. Lets say they are apple, car, and clock. The first tab needs access to al...
We are a small team doing work on a LoB system that needs to connect to varied systems such as ERPs and CRMs to extract business processes like invoices, customer info, production orders and the such, for internal use of the application, and then return some specific result to the ERP. This is a real-time operation, no...
I want to store store some app specific secret on the phone - this should be available only for the app & no other app. I was looking at DPAPI - however, if the user does not have a logon password, then it seems like the master key will be accessible to everyone. Also I am not clear what else to pass as the entropy ...
I have created two lists of objects: One is records from an xml and the other is records from the database. The rule is check if the record from an xml exist in the database then exclude. I have thought of two options: First is to loop the list of records from an xml and for each record check if the id exist in the da...
I’m currently building a dashboard to view some analytics about the data generated by my company's product. We use MySQL as our database. The SQL queries to generate the analytics from the raw live data can be a bit complicated and take long time to process. So I put in place some batches that run every day or every ho...
I just developed an algorithm and additional to the usual unit tests I wrote a profiling "test" that I was using to measure and optimize its performance. It is structured similar to a test (arrange: setting up a sizable chunk of data to process, act: run the algorithm) but without the assert stage (it doesn't test anyt...
What if I have a class X that does the following: Read a file (within its own class). Parses the file by calling a Parse class Processing the parsed file by calling a Process class Outputting by calling an Output class I would assume the single responsibility is reading the file, but the other functions (parsing, pro...
I have a program which includes lots of header files but it do not uses all the header files. I have removed some of them although it is working fine. I did not notice any changes in the performance. Will this affect code size or something else. Can I include header files as much as I want without affecting the code...
I'm just getting used to unit testing and on my new project I decided to adopt a TDD approach. My code below is to test the UserServices class which is responsible for creating a user, deleting a user, checking if a user exists etc. Am I on the right lines? I ask because everywhere I look it discusses mocking and I can...
Does passing the entire object as argument rather than just a property of it, in javascript, effect performance? For example: <input type="button" onclick="getDetails(this)"/> vs <input type="button" onclick="getDetails(this.sourceIndex)"/> even if I pass the sourceIndex property of 'this' object, I would retrieve t...
I've been trying to find a good way of solving the following problem, but I'm not sure how to even frame it. I think there might be relatively well-known solutions I'm not familiar with, since I don't have much knowledge of algorithms. How could I approach this? Example problem: There's a known begin-state A and known ...
Our web app generates a large amount of logs. These logs include both events regarding background operations in the app (data arrives from the server, ajax failures, inter-component communication, etc.); and also user initiated actions (user clicked a button, user wrote text, etc.). We built our own logging library wit...
I'm looking at a new project to be developed in .Net, and I'd like to do it the right way. I'd like to create a solution with 3 parts : a front- and a backoffice, both using a the third part as model. In my mind, all DB connection related infos should be stored in front- and backoffice, but then, how should I handle D...
My question: When you've got a complex converter like, that takes chunks or large result sets out of a database, converts it into a line by line file/resource in the end, should one either design it as std::basic_streambuf or should it be a std::basic_istream or something different, using C++?! To better describe it lo...
I'm doing some research for a project in which I will need to create a service which can handle millions of requests per minute. Clearly I want to use an asynchronous programming model to make the best use of threads and resources. But memory usage and speed are the top priorities. Looking at the original APM (Asynch...
I find myself right now banging my head with the following issue (in PHP): I have an abstract base class, which has a non-abstract method, inherited and unchanged all over the inheritance chain (which is 3-tiered right now, only the first tier is abstract). This non-abstract method contains logic to calculate a disk pa...
Back in the days of 8-bit machines there existed an educational word game. I have no idea what it was actually called but for the sake of this question (since it involves pyramids) let's call it Stones of Giza. The game was simple. Starting at the top level, a letter was added to a single letter word and another word w...
I have a collection of cooperative classes whose behaviors are interdependent upon one another. But I wish to keep them loosely coupled, so I've created appropriate interfaces. I want to determine an appropriate pattern to instantiate specific implementations of these objects. Here's an outline of their interdependenci...
I'm migrating my monolithic web application to a microservice based one. I'm going to use Spring cloud and I've got a discovery service where all the rest of the services are registered. A simplified schema of the architecture is drawn here: Both Equipment and Task services have their own RESTful HTTP API. They take c...
I found this code example explaining Open / Closed principle. Code before application of principle: public class Logger { public void Log(string message, LogType logType) { switch (logType) { case LogType.Console: Console.WriteLine(message); break; ...
Let's say I have a very long method which basically creates a responsive and resizable layout for a user interface by using a few fixed values and a few variable ones taken from an element's coordinates and width/height sizes. To obtain the desired layout, my code needs to perform basic but repetitive math operations (...
Scenario: application will search in database almost all columns across about 8 tables/views for defined string and return all rows containing that string (will return collection of objects or JSON). At beginning database(DB2 v6) will contain about 100k records Which approach is better: Loading these tables and mappin...
One of our assignments is to write a website which should use a database. I would like to have some help organizing it. Here are characteristics of our work. The assignment is for a group of 5 people. We have access to a server, where each person of the lecture has an account and a database (MySQL). (Some haven't seen...
Edit: I have found a closely related question: StackOverflow This question is not about the differences between functional and acceptance tests! Almost all the info I could find on the web just explains the difference between them. I know that functional tests (FT's) address fringe conditions and bug scenarios, whereas...
Abstract Syntax Tree Metamodel (ASTM) is an OMG standard to represent ASTs. In my very partial and limited understanding (I only spend an hour or two glancing into that spec), it is notably defining some XML representation for some kind of ASTs, and claims to be some kind of universal representation. However, after hav...
The article on the Single-Writer Principle of the Mechanical Sympathy blog explains how bad queues are (performance-wise), because they need to be able to receive messages from multiple produers, and how instead we should be using only single Consumer-Producer pairs in our systems, like their "Disruptor" does. But I fa...
I got something here that bogs my mind a bit. Let's say I write me this API (in TS), check out some of these properties: export class MyAPI{ propertyThatShouldContainSuffix:Array<string>; // like .jpg or .mp3 somethingElses:Array<SomethingElse>; //instances of some class enumProperty:SomeEn...
Source code analyzers (like SonarQube) complain about float (or double) equality comparisons because equality is a tricky thing with floats; the values compared can be the results of computations which often have minute rounding effects, so that 0.3 - 0.2 == 0.1 often returns false while mathematically it should always...
Some articles (JavaScript Module Pattern In Depth, Mastering The Module Pattern) describe defining modules in JavaScript like in the snippet below (from Addy Osmani's "Learning JavaScript Design Patterns"): var testModule = (function () { var counter = 0; return { incrementCounter: function () { ...
To simplify the interface, is it better to just not have the getBalance() method? Passing 0 to the charge(float c); will give the same result: public class Client { private float bal; float getBalance() { return bal; } float charge(float c) { bal -= c; return bal; } } Maybe make a note ...
We use TFS and Visual Studio 2015 at work but don't get full benefit from the ALM features as we have code in non-TFS Git repos. We would like to integrate these products in with all the TFS goodies like checkin-to-work item linking, in-IDE pull requests, etc. Is there any way to access these features in a non-TFS-host...
I would like to ask a follow-up to a question I just asked: Better to have 2 methods with clear meaning, or just 1 dual use method? I now understand why it is best to separate charge(float c); and getBalance();. But, every method has the opportunity to return a value. So, maybe use that opportunity and just return a bo...
The C preprocessor is attached to C, but it has a completely different syntax from the main language: syntactically significant whitespace (end of line terminates a statement, gap after the macro determines the start of the replacement list) keyword-based blocks instead of braced blocks, elif instead of else if keywor...
I am developing a suite of applications that will be hosted in Azure. Some apps will be for customer use (not public tho, i.e. invited/paid up customers) and some for internal employees. For authentication I was initially going to use something like the excellent ThinkTecture IdentityServer. This would allow me to ...
Say you have a document like this: <names> <first>Joe</first> <last>Smoe</last> <phonenumbers> <phonenumber type="home">123-567-9876</phonenumber> <phonenumber type="cell">345-678-1234</phonenumber> </phonenumbers> <emails> <email>abc@dfg.com</email> <email>xyz@lkj.com</email> </emails> ...
What is the point of hidden files? In Microsoft Windows they exist, in Mac OS X they exist and in Linux they exist. It seems to me that it just makes detecting malware more difficult. The only upside I see is protection of necessary OS files.
I want to prevent installing apps using third party app stores but except only one app store. This specific app store is in my control. I can change it's code to send a message to the mobile device that this store is special. I can disable Unknown sources setting in security settings using android API according to th...
We know that Charles Babbage designed the first Turing-complete mechanical machine - the Analytical Engine - in the 1800s, but it was never actually built (not yet anyway). In recent history, at least one mechanical Turing machine has been built. (This example is in fact a Universal Turing Machine, albeit with finite ...
We have a simple REST webapp which is dependent on multiple external services, mostly Kafka messages. An attempt was made to isolate external dependencies by encapsulating all external interactions in a separate webapp, and make the core app communicate with the external interfaces app only through an internal kafka to...
I see a lot of NodeJS articles recommending the Bluebird library for promisifying your code and avoiding callback spaghetti. Is there any value in using such a library when using Node 4.2.4+ given that ES6 has native Promises? What can I do with Bluebird that I can't do with ES6 promises? The Bluebird documenation is s...
ISO 12207 contains interesting points for design verification: a) The design is correct and consistent with and traceable to requirements. c) Selected design can be derived from requirements. EDIT Also under Core verification, it reads: c) Selected code can be derived from design or requirements. What is the diff...
I have been having this idea of using encryption to prevent users from figuring out content in my program outside of the program itself. Like users may find textures never used in the game meant to be part of some kind of Easter egg while going though the games data. This may e.g. ruin it for everybody if posted online...
Can a single SQL Server connection be shared among tasks executing in parallel? Each task would dequeue an item from a ParallelQueue, instantiate a SqlClient command, and insert a row into the table. Or does each command-instantiating-task require its own dedicated connection to the database? Can the connection(s) be i...
I ask my question on programmers because: no coding is really involved this question is very conceptual concerning an exchange protocol. Bit of context: When you implement Bluetooth, like I do, you have to choose between multiple protocols, such as L2CAP and RFCOMM. RFCOMM relies on L2CAP protocol. Question: Are ther...
I'm getting beyond a simple MVVM program now, and I'd just like to sense check my current architecture and makes sure I'm going down the right path here. Everything is structured around screens, and these screens have a kind of "tree" breakdown. On the top level there's a home screen, and you can drill down through rel...
The Redux framework favors immutable state/pure function paradigm, which promotes creation of new state from the previous state in terms of the current action. The applicability of this paradigm is indubitable. A major concern of mine is that, as the Redux reducers eagerly return fresh new states from previous states ...
What are some reasons you may choose a worse runtime algorithm? And what are some advantages of a linked list vs a hash table/array where access is constant time.
Today I had the idea to write a program that compares the prizes between different web-stores. The key question I am asking myself is how to find (with a high probability) the same article on another web-store again. For example: Three different websites to search on are hard-coded into the code: A, B and C. Every arti...
I have received an XSD from a 3rd party supplier generated from a Java based system; which is to be used to create a SOAP endpoint for us to receive data transfers. Their XSD does not make any use of the nillable attribute defined within the W3C/XSD namespace, for example: <xs:complexType name="Customer"> <xs:seque...
I understand that it's extremely depends on a particular case, but I really would like to know at least roughly how long a specific task can take for completion to average programmer. Is there any examples of pairs like "project - completion time"? I'm absolutely ok with my own time-estimation abilities. So is my emplo...
Please advise me and correct my understanding if I am in error. In my opinion, any programmer wanting to develop an accounting system should consider two approaches from the two mentioned below: Make all clients connect to SQL server directly by changing the connection string in all clients to refer to SQL server. Mak...
I've dabbled in a few MVC frameworks (like Rails and its ilk) and I've noticed that the file that defines restful routes often go separate from controllers which hold the actions executed through those routes. For example, let's say that there is a route /users That go to UserController.create action. I would expect ...
I'm about to add some user account and password functionality to my software, so I'm reading about password hashing. So my understanding is Hashing is a one way function, and it works like this: User Bob Types in password box: “MyPassword” Request Sent to server for Bob’s Salt, and hash from database: Hash: 8912ep98as...
One of Bloch's Effective Java items 55: Optimize judiciously extends Jackson's rules on optimization: Rule no. 1: Don't optimise! Rule no. 2 (for experts): Don't optimise yet! Extra Bloch rule 1: Don't try it until development is finished. Extra Bloch rule 2: Measure performance before and after implementing an optimi...
ES6 native promises do not allow you to synchronously check if they're resolved/pending/failed or to extract their value. I sometimes need this functionality and thus I have to code it manually. Is this considered an anti-pattern? Is this why this feature was left out of the standard? This is a situation where I think ...
Is providing a user login a non functional requirement? Since this is concerned with security which is a non functional requirement, I feel that providing a user login is also non functional but again I feel that it is functional.