instruction
stringlengths
34
36.1k
I have no idea where to start in all honesty. If I make a phone app, for example, how would I go about only allowing people with a university (college) email address to sign up? Would it be as simple as verifying that the input is in fact an email address and then just sending a verification code to that email address?...
Here is my problem, I have a task to create an android app to display data from our SQL server, the problem is our SQL server is not online. We have a MySQL server too, the MySQL server is online, so I came up with the idea to mirror data on SQL server to MySQL, because our SQL Sever is not online, I have to use anothe...
In many programming languages, arrays don't get as much attention as other data structures. In Java, there is no Array<T> type collection to make arrays feel more consistent, such as in inheritance. In Python, there are no arrays, but instead only lists. To have an "array", one has to do something like [0] * size. Arra...
The current way of knowing if a BigDecimal is greater than another is bigDecimal.compareTo(otherBigDecimal) > 0 (or one.compareTo(another) == 1), but I find it too clunky and unexpressive. bigDecimal.isGreaterThan(otherBigDecimal) is easier to understand. For people who are used to Java and know how compareTo() works,...
I have a very complex math formula/equation which involves exponential. Formula: X + 2 = Y *PS: The above is just an example to illustrate my problem. The real formula is way more complex than this. There is no way for me to form an equation with X variable on the left like X = Y - 2. I tried professional Math softwar...
Are there any programming languages where the default value of a string is "" ? If so, what are they?
On OLX like Website , Anytime a user posts a new ad. It comes in top of the page. No search is involved in it. Which technology we can use to make such functions. Suppose X is visiting my website abc.com. Should I fetch database each time and generate page dynamically ? or There is a better approach to to that. Ques...
I am looking to implement a custom autocomplete functionality for a travel website with huge amounts of data. I am thinking of implementing it using a trie. But how do I handle it if the data cannot fit on a single machine. Also how can I get the top five items for a query.
I usually analyze data of experiments and although I have a general schema of steps I need to do, I might need to tweak it to the specifics of the experiments or the questions behind. I am usually the only one coding. I looked at wikipedia but I am unsure which methodology I can use, partially because I have never fo...
I'd like to make an app that has all features enabled for two months, and some disabled afterward. Is that allowed on Google Play or iOS? The iOS app store guidelines say that: Apps that are "demo", "trial", or "test" versions will be rejected. If an app has all functionality disabled after a period, it's obviously a...
I am not able to search for algorithms which can help me solve this problem, I am not sure under which category this problem falls or which algorithm to use. Problem statement: There are N number of suppliers who supply Sugar, each supplier has Supplier Location (latitude, longitude) of their warehouse from which they ...
I'm making a video game and and I would like to know if my OO Inventory System has any flaws or oversightes. Here is the the item system anything that can be stored in an inventory system is an item. The composition of the item class is a shield,a weapon, an engine, and a ship. Item: Ship ship Engine engine Weapon we...
I'm currently working on expanding the capabilities of my pet programming language project's type system, and have come across an interesting area where my research into other language's type systems hasn't taken me before. As background, my language is an object-functional language with static types and partial type i...
I got a webservice that accepts multiple calls that require different handling and validation, using generics I've managed to create a common class that accepts a handler and a validator and it looks like this public class PetitionService<T1, T2> where T1 : Headers, Petition where T2 : Headers { Petitio...
Can someone please highlight the definition and differences between data intensive and form intensive web applications.It would be really helpful if suitable java based web application framework or technology stack that is suitable for each kinf of architecture is highlighted. I just was doing research on feasibility o...
Is the following design flawed? Basically I have a main class used to create an object of a type and then return it as the main interface of the type. The problem with this is that each of the classes that implement the interface all have different properties that need to be set. So I then have to cast them back to the...
I have a dictionary of words and a stream of incoming characters. I need to create a map of words present in the stream along with their frequencies. How can I achieve this efficiently?
.NET applications developed using Visual Studio have an easy way to store and recover user settings. You can add the default value of a setting in a special class and have read/write access to it at run time through Properties.Settings.Default.SettingName. Some applications have use for values to be remembered between ...
I have an application that is beiong split out into a number of services. From a previous question on here, I think that initially JSON/REST is the way to go for communication. Some of my micro services need to be available publicly, for 3rd parties to use. So I am now wondering about the best way of structuring this. ...
After taking a look to SCRUM it doesn't same to me "enough" to lead a project since it isn't disucssing the technical side of it, so my questions are: 1-is it possible/recommanded to combine SCRUM with some unified process or any other software development process ? How to make specifications in this case? 2-What about...
I am a product owner on an agile team. I when doing PO acceptance testing I usually make note to try some edge cases. Its not uncommon for me to discover something and then I pass it back to the the devs. I am getting push back from one of the developers when I reject his stories. He says its unfair since I don't speci...
Suppose we have a function f that gets a complex (non-flat) object as an input, serializes it, calculates hash of serialization results (e.g. md5) and returns calculated hash. It may use some exiting serialization method, e.g. msgpack. But are there any known techniques that may be more efficient than full (reversible)...
I would like to create a front-end interface in HTML that interacts with a Java program via an HTML form. I would like to be able to publish this project on the Internet. In other words, the text entered in the input fields of the form would be sent to the Java program as arguments once the user clicks "Submit". The Ja...
I currently have a web application running with my own backend, but maintaining it is becoming a bit painful so I was considering the option of using an existing BaaS (Firebase). The main problems I want to resolve by using Firebase are: Better and more reliable authentication, including other sources of authenticatio...
I am having a hard time to understand cyclomatic complexity. I went through some videos in youtube for this. I got negative value for cyclomatic complexity when I use this formula M = E - N + P. I found this formula as well E = E - N + 2P. I would be happy to get some brief description about cyclomatic complexity and w...
We are making a quiz application, I'm trying to integrate my Angular 2 UI with the REST api. Our Quiz domain model consist of the following (simplified) hierarchy: -Quiz -Category -Question -Choice where parent doesn't know its children, but child knows its parent. For example, Choice has a reference for a Question, bu...
I am designing some polymorphic code to perform mathematical operations. The idea is to abstract out the underlying representation of the data, as different use cases require different representations. Operations can only be performed with data of the same type. There are many algorithms operating on these things and a...
I'm fairly new to programming (about four months learning), and have decided to mess about with an attempt at writing a language in C for both fun and practice, and am wondering how objects are implemented when you get down to it. At the moment I am just looking to turn my 'code' into a c-file, and then compile that, s...
When you consider Scala and its pass-by-name you could (if I am not mistaken) pack the argument to lambda and pass it by value to the function. Internally the function would use pass-by-name parameter as lambda. However in Algol you can change the parameter (so it is possible to write swap for example). My question is ...
I get confused over min and max functions, in certain contexts. In one context, when you're using the functions to take the greater or lesser of two values, there is no issue. For example, //how many autographed CD's can I give out? int howManyAutographs(int CDs, int Cases, int Pens) { //if no pens, then I cannot...
I have a for loop in C# as below, int[] dim1, dim2, dim3; //Initialize dim1, dim2 and dim3 for(int i = 0; i < dim1.Length; i++) { DoSomething1(i); for(int j = 0; j < dim2.Length; j++) { DoSomething2(i, j); for(int k = 0; k < dim3.Length; k++) { DoSomething3(i, j, k); ...
As a part of my master's thesis, I am carrying a research topic on why there are no cross platform mobile applications. As applications developed in Java can run on any operating system using the JVM, I was wondering why there is no interpreter like JVM for mobile devices through which one application can run under var...
Redux is essentially functional programming, and it makes a lot of sense. As I move back to a non-javascript OOP language in a different project I would like to apply the same principles such as single state object, reducers which act on parts of that state, a business layer of semantic actions to modify the state. My ...
at the moment I have one repo (git) for my project and I use branching techniques for development. This is a very new project and I wanted to get things right from the very beginning. I will create this app for Win32, Win64 and OSX. Now, I want to introduce builds (not really nightly as I am sole developer but frequent...
I have a solid set of classes that do the following build tables from data and templates advanced form serialization build forms from data and templates launch overlays with forms/wizards short poll for new data post data ..etc Basically a lot of little classes and modules that work independently. Now I want to write...
I'm working on a high-performance project where Java 8's lambda functions are enormously useful. I've found, however, that they're memory inefficient when used en masse. For example, suppose I need to apply a lambda function 1,000,000 times: for (int i = 0; i < 1_000_000; i += 1) { collection.forEach(thing -> thing.f...
I have to share parameters/information between two independent applications: an Executable and a PDF file. By clicking a button within the pdf I want to perform some specific task (or run code) in my exe standalone player. But I am confused about: How do two independent application talk to each other How will I write...
We are about to start using FreeRTOS with lwip and mbed-tls as a platform for new products. We're working in an Linux environment and I'm tasked with setting up our first project. In Linux we typically have the platform (distribution) as a repository and then repos for all our applications. With the RTOS I'm not sure t...
Background Our project, written in Java, is now trying to eliminate unnessceary external dependencies introduced during prototype development. We feel it easy when killing simple static utility methods, later we got a problem. Our project make heavy use of LazyInitializer from apache common-lang3 to implement Singleton...
So, I'm taking a MIPS course after returning to school; and we're approaching the point where we begin on our final project. I've always been one for large, well-structured projects: lots of supporting tooling, well-segregated zones of control and concern within the project, extensive testing, so on and so forth. Unfor...
Did I do something wrong in my code organization ? I still find my own program difficult to follow. I tried to decompose my program on small, easy to understand classes and functions, still I find myself jumping around to follow action process. I can't post my entire project here, so here is a sample of a process. My ...
I am developing internal Android apps for the company I work for. In various places in the apps I need to connect to an internal server. This server is shutdown for maintenance for a period of time every night so there are times when it is not available. There may also be times when the wi-fi connection on the tablet ...
I have a simple web application built with Angular which fetches some state from a web server and shows it to the user. Additionally I want to implement a feature where users are able to customize the view of this application by dynamically appending new code on the rendered page in a way that the changes would reflect...
I am creating an application that will manage job interviews and help the employers to choose the job seekers based on a ranking system that's based on some user info. I've created a database that has the following tables: UserTable (stores Username, password) Role Table (stores the Role ID, name and description. The ...
When following the standard service and repository patterns, should your repository contain a specific method for every database operation or should you just use the general methods, e.g. update? Take for example the following service method: DisableUser(User user) { user.enabled = false; userRepo.update(user);...
Is there a commonly (or rarely) used pattern for a "confirming you want to do this" message when calling a function from a library? I have a API that exposes some operations that are potentially dangerous if misused (would cause unwanted changes to the database). I would like to pass a warning back to the caller to do...
Suppose I have an interface Employee and there are many classes that implement it, such as Bob, Joe, and Mary, none of which may be changed. public interface Employee{ public void work() } public class Mary implements Employee{ public void work(){ //Mary's implementation of work } } I must make a Manager cl...
I've recently been writing some code that deals with 3rd parties -- obviously errors will happen so I'm using Either/Maybe monads where appropriate. As this is C# I'm also using async Tasks too. My problem is after it's all said & done my return types are quite verbose. e.g. Task<Either<ApiErrorEnum, ActualApiResultDt...
Background I have an interface defined for a circular-buffer called ICircularBuffer in a separate project. This ICircularBuffer is something that we use all over the place, so it resides in the CommonInterfaces project. Well, we have another interface IEquipmentController that controls some very distinct piece of equip...
I've noticed my software severely degrades when the # of threads is substantially increased. What I mean is that when I limit the # of threads, the performance is much better than when I just let them all run simultaneously. My cpu is an i7-3940XM, so very fast for a mobile and still not too shabby compared to desktop ...
I'm working on creating games on OS X, using the Cocoa framework, the probably only and best way to utilize all the capabilities of this operating system. Since Cocoa is MVC, I have to frame my games around this style. Is there any problem with framing your game using a MVC design? What can I do to make game developmen...
I'm very comfortable with Swift, Obj-C, and Javascript but for a new project I need to use a library that is only available in Python. How do I integrate python or python scripts into an OSX project? There is the option of going PyObjc or pyapp to build the entire application but that seems extravagant given that I onl...
I saw this question that shows it is impossible to programatically determine if a javascript function is pure, but is it sometimes possible to affirm that a function is pure - so something like... function sq_a(x){ return x * x; }; // no side effects, all variables local function sq_b(x){ return pow(x, 2); }; // if `po...
I have a function that is called by myStruct *structName = myFunction(0); The function looks like myStruct *myfunction(int x) { if ( x == NULL) { return NULL; } /*rest of code*/ } Passing NULL or 0 BOTH trigger the if (x== NULL) statement and I can't figure out why. I need to return from the fu...
I'm designing a web application. I'd like to use sub-domains to split the site into logic separate sections based on some category - exactly like the stack exchange websites do. I'm currently aware of two approaches to this ... One large application that gathers context from the current domain (or some other way) and ...
Last year, in university we used the library SDL to create a game from scratch. So I though of developping a game engine based on SDL. I will be using Qt to do the UI and SDL to implement the core of the engine (collisons, physics, game logic etc...). The game engine will be a simple application, for example the user c...
Most people say when building micro-services, that it's best to have separate databases for each of the microservices. E.g: User-microservice: DB - User userId name Etc... Review-microservice: DB - Review userId | The user who posted the review Review-description But I've been thinking, is it best to have a O...
For example, I have a game, which has some tools to increase the ability of the Player: Tool.h class Tool{ public: std::string name; }; And some tools: Sword.h class Sword : public Tool{ public: Sword(){ this->name="Sword"; } int attack; }; Shield.h class Shield : public Tool{ public: Shi...
Consider the following CI procedure is in place: Builds are only deployed (semi-)automatically. All changes are version-controlled. Configuration is fixed per environment. Why use data files (*.config in .NET) versus code for configuration? Yes, it would technically be "hard-coded" although still centralized rather t...
Here are two links which briefly describe the difference between the two: stateless, stateful In short in the "Stateless" scenario we bind views directly to models, view models just expose the whole objects, not their properties, so we don't need any synchronization between models and view models. In the "Stateful" sce...
I am really reconsidering my current class hierarchy for timeslots (in a schedule). I wanted to make them as flexible as possible so it would cover many possibilities of what we could understand as a timeslot, so I ended up with this design: All timeslots share a chronological/hierarchical order so we're able to define...
Consider that you have some graphical interface that represents some data structure. For example a text field: This field is connected to the data structure through events. I tried to make diagram of this: Of course, there may be many GUI element and the structure can be complex. What happens is, that when GUI values...
Let's say I got a series of services that are handled by a central hub, part of the behavior of the application is controlled by a series of settings that are stored on a file. Right now when I get a request and create the handler for it I inject an ApplicationSettings object that would allow the object to access the s...
A question that gets asked a lot is "Why use low level languages if you can code in high level languages more easily (and often tersely)?". I think the answers are fairly straight forward here, being mainly efficiency concerns. However, I pose "Why do we use high level languages in the first place?". Besides the fact t...
Why are some programming languages such as Python or Julia considered to be "scientific" programming languages? I guess my real question what is the criteria that makes a programming language scientific?
I have a situation where I have an external library. In short, I need to be able to adapt my type to theirs, and theirs to mine. The library has a collection like so: interface IExternalCollection { void Add(IExternal item); IExternal Get(int index); } Now, let me start off by explaining the most straightforwa...
I must persist handful of properties for several games in relational DB. No other type of DB can be used. Number of games will be around 4-5, and number of properties is (for now) kind of small, but maybe it will grow later. It is almost guaranteed that all games will have same properties (same "keys" to say, not same ...
Based on the List monad I set out to define Monad instances for the Map type from Data.Map, to perform chained unions and folds on Maps like lists, but with the efficient sorting and merging of Maps: {-# LANGUAGE FlexibleInstances #-} import qualified Data.Map as M instance Monad (M.Map Integer) where return = M.si...
Why do people prefer var is None over var == None when is can be used on few objects only?
Background Okay, so let's say I have some high priority (ThreadPriority.Highest) thread t which needs to enter a critical region in order to consume some data. I will use the following code snippet to illustrate my point. // create a consumer thread t = new Thread(() => { Monitor.Enter(myLock); // consume data...
TL;DR: To access DB functionality in my codebase I currently use a custom layer throughout the code. The layer needs an upgrade in order to begin accepting prepared statements, which it currently does not. I have a choice between abandoning using the custom layer in favor of using another layer directly instead - su...
I am planning on converting an old project originally from Objective-C to Swift. The project is currently under the MIT License, and any distributions of it must maintain the same MIT License. However, as far as I know, this only applies if the current code is used, but after I convert it to Swift, the whole syntax wou...
It looks like a weird design choice, because a Dictionary and an ImmutableDictionary are quite different write-wise. (Read-wise, they both implement IReadOnlyDictionary, which is fine*) In fact, the current implementation of IDictionary<TKey, TValue>.Add() in the ImmutableDictionary class throws a NotSupportedException...
Does PI planning actually plan for only a few sprints ahead or does it plan for the whole project(all sprints until production)?
I have a hashed value X and need to ensure that any of the data sets D1...Dn can be concatenated with a correctional value C1...Cn and passed into a hashing algorithm to result in the value of X. What I need is a way to figure out what Ci should be in order to ensure that hash( Di ++ Ci ) == X. If I use a simple hash...
I am trying to figure out what's the best approach when dealing with object references in a JSON to be sent to my server for deserialization. To clarify, what I mean is how to refer to data contained in the JSON body itself. For the example let's use the following (incorrect) JSON body: { "players": [ { "name": "...
I think most of us strive to make our code run smoothly, read logically, and altogether function well. But for those who really enjoy taking the time to figure out how to optimize already good code (whether it's their own or someone else's), where do these individuals best find themselves in the programming world? Whet...
I'm in an introductory programming class and we're only in lesson two, so try to keep terminology simple, ha. I'm a bit confused about when you need to and when you don't need to initialize a variable. My book says initialization is when you assign a value to a variable after it's declared. I later looked at my lang...
I am parsing a infix math expression to a postfix form. I want to store it in a list like [4.5, 3, 0.25, +, -] so that I can process it once it's parsed. I could store it in a string again, but I would have to parse it twice. The problem is that I don't know how to store operators and operands in the same list. I thoug...
I'm trying to learn how the MVC pattern works so have been playing around a bit. I just wrote this, which was making sense to me, until I wanted to display the array content which has been collect by the Controller class via the View class output() method. <?php class Model { public $arrayPeople = array( ...
I've recently started designing apps in Android Studio, and I've noticed that the same operations (for example, using a widget) can be completed by either going into the activityname_java file and creating the widget as a java object, or by going into the activity_activityname.xml and using the combination of drag-and-...
Sorry if I got the wording wrong in my title, but it would be easiest to provide an example in JavaFX primaryStage.setScene(new Scene(grid, 300, 275)); Now from what I understand, this code is instantiating and initializing a Scene object, but it is not declaring it. If this is the case then would it be right to say t...
What is a group/family of functions that is random but some number(s) are more likely to come? For example, calling each of this fake functions 10 times give: random2: 2,3,2,4,2,6,7,2,2,2 random4: 4,1,2,3,4,4,2,1,4,9 As you can see, random2 gives more number 2, random4 gives more number 4. Both functions have some pa...
I am working on this project of mine where I am the only developer. I have chosen git for the version control for the project. Currently, I work from multiple systems and commit to the master branch of my central repository. I wanted to know if this is a proper strategy or I am missing out of any helpful Git feature. S...
After learning OOP design then I got to know my programming way was not correct. One should convert physical entities or logically separable components into classes which are reusable and have their own behavior and properties. One must not simply convert all the entities into objects because that would be really cumbe...
FNV-1, Murmur2, and DJB2 are examples of non-cryptographic hashing functions used in actual applications (see Which hashing algorithm is best for uniqueness and speed?). These are all similar in that they have an inner loop that computes the result by using simple operations such as XOR or bit shifting. Perhaps these a...
In javascript you can't use statements in expressions. Because of this you are forced to use logic and ternary operators in an expression when you want to use if or switch etc.. Since I didn't want to use ternary operators everytime I do a condition check, I've written simple functions to do condition checks. Using the...
Context I have modified a lot a software that in under Affero GPL. I have contributed back what made sense, as it has a completely different direction. I plan to build a SaaS around it and charge money for its use. The code is public, with both copyright notices in the LICENSE file: mine and the originals. In our t...
I am struggling with the following issue. Let's say I have a component that performs operations on guests and rooms, and uses a number of abstract interfaces, along the lines of: class HotelManager { public HotelManager(IRoomsRepository rep, ILog log, ...); public void PutGuestInRoom(string guest, int room, Da...
I think that the type names in Rust are much better than the ones in C. I'd choose f64 over double and u32 over unsigned int or uint_32t any day. Is there any reason (other than tradition) to use those counter-intuitive hard-to-learn names? I know that names like short and long are architecture-specific, but doesn't th...
A private company allowed me to use their API to make REST API calls (using Basic Authentication) in my application's server side. They also asked to see my implementation before I can go live. From their standpoint I understand they would like to make sure the API keys are secure enough. From my standpoint I would pre...
In many cases, it is useful to have a constructor or factory method that validates arguments before instantiating an object, returning a new object if the arguments are valid and null otherwise. But in traditional javascript constructors, you're limited in what you can return. In particular, you cannot return null. ...
I'm designing a RESTful API for my organization. We do use password-based authentication, which generates tokens. One part of our API requires that the users be physically in the office, i.e. there is no use case where someone would need to be using those particular endpoints while working remotely. (It has to do with ...
In the following link, the author states that We have already reasoned that ‘out’ is a static variable belonging to the class System. But now we can see that ‘out’ must be an instance of a class, because it is invoking the method ‘println()’. But how can a class variable, i.e. static variable, be an instance variabl...
I have a problem how to go about naming my namespaces and classes. I already figured they shouldn't both have the same name, as it causes all kinds of problems. Most notable problem for me is that I need to fully qualify the class or make an alias. Here is what I have: Model.DataSource.DataSource Model.DataSource.FileS...
Suppose I have a parametrized data type with more than one nullary (constant) data constructor, such as: data Check a = Valid | Invalid | Unsure a Sometimes I want to manipulate the non-constant constructors with a function that keeps the nullary constants fixed, and I hope to do it like instance Functor Check where ...
We are developing an e-learning website where you can practice LearnItems (typically words of a foreign language). The concept is very similar to Memrise. When a user practices a LearnItem, a Result object is created (it contains the date of the answer, plus a flag to indicate if the answer given by the user was correc...
This post felt like it belonged somewhere in between SE Workplace and SE Programmers. However, since it's specifically targeting a programming issue, I decided to put it here. What are the responsibilities of an architect? I'm asking because at every company that I've worked for, the architect's duties were along the l...
If it possible IList <dynamic> = new List <dynamic>; or class A <T> { } class B: A <dynamic> { } Why it is not possible to do class U: IEnumerable <dynamic> {} ?
This answer describing how Spring for Java works instantiates an object of type Interface which is illegal yet it received 21 upvotes. Why is this answer upvoted for illegal behavior? Spring contains (as Skaffman rightly pointed out) a MVC framework. To explain in short here are my inputs. Spring supports segregation o...