instruction
stringlengths
34
36.1k
My question is related to when should a database table be broken into multiple tables with relations? However, I have a clearer one-to-one relationship than in that question. If I was designing the following table from scratch should it be in one table or two? ORDERS id date total_amount is_paid paid_date paid_amount h...
Does a UIView object with an embedded UIButton and IBAction violate MVC principles? Example: class MyView: UIView { @IBOutlet weak var myButton: UIButton! @IBAction func myButtonTapped(sender: AnyObject) { // do something } } Are controllers the only objects that are supposed to perform actions? ...
Let's say I want to store date which cannot be changed by the user in code. For example, my application supports ten types of reports, and I want to store metadata about it. Usually, I'd use a constant dictionary for that: Private Shared ReadOnly ReportConfigurations As New Dictionary(Of Reports, ReportMetadata)() From...
I have code that looks at numbers 1 - 5, and counts how many occurrences of those numbers appear in an algorithm. What is an algorithm for finding the average number of 1 - 5 by counting the occurrences? Example: 1 occurred 10 times 2 occurred 27 times 3 occurred 15 times 4 occurred 34 times 5 occur...
In the Python ecosystem, there are two related but distinct concepts called "package": A "dotted module name", represented in its source as a directory with an __init__ module (i.e. an __init__.py file) (+ usually more modules/*.py files and sometimes nested packages) in it A software unit distributed via PyPI - the P...
I am Developing a E-Commerce Web Application as a part of my learning using Spring Hibernate and AngularJs. I have written some Rest API's Controllers in Spring and then from the Web Component i am invoking the same using Angular Js like the below :- storezillaadminapp.service('CategoryService',function($http){ ...
I have started learning streaming APIs and I found one of the good documentations here. There was a comparison given by author to demonstrate the effectiveness of the streams. var http = require('http'); var fs = require('fs'); var server = http.createServer(function (req, res) { fs.readFile(__dirname + '/data.txt...
So I recently found some homebrew software for the Nintendo DS (NDS) which I like to use. But I have a Nintento 3DS (3DS) with homebrew enabled and I am thinking about porting it to the 3DS. I want to make it open source and on github. Now the source code only has a license.txt (GPLv2) in the root directory. There's no...
Lately I've found myself inserting magic numbers into code to make it more readable. I've done this in situations where the magic number is only used once and its purpose is obvious from the context. An example from a recent project: /* Extract id from "/toClient/chat/id". */ String channelId = channelIdWithPath.split(...
My team is very inexperienced in how manager our only work and how much time is necessary to spend in some tasks. So many sample things like just develop what our client needs and show it for her (like agile methodology) are transformed into boring and unnecessary meetings which some members try to guess what the custo...
Given a list of circles (each with parameters (x,y,radius) ) I want to place another circle with a fixed radius such that it overlaps the maximum possible circles from the list of circles. As long as the placed circle overlaps the optimal amount of circles, I don't care about the exact placement (i.e. if there are mul...
I've just inherited a HTML/CSS based internal UI library, which the place I work is planning to use to standardize CSS styles for all of its products across the board, mainly webapps. The library has code that is in a style similar to bootstrap, however there are also separate css files for each of our clients inside t...
I am new to wpf c# and MVVM approach. I have a working program that demonstrate the MVVM approach in wpf c# (by copying some code from the internet and applying it to may program). I have used ObservableCollection in my viewmodel and add my own object here. As I have said, it is working fin but the problem is I only ha...
I heard that one of the main problems applying neural style to high resolution images is the huge amount of memory that would use. Also I just configured a network using tiny-cnn This is my calculation for number of weights and number of neurons per layer in my example: conv_layer_# height width depth filter_height fil...
I'm working my way (slowly, but surely) through a book: Introduction to Java Programming, 10th edition, Comprehensive, by J. Liang (ISBN10: 0133761312) It explains the idea of a reference variable in a way that I understand. However, the idea doesn't seem intuitive to me. This makes me think that I'm missing somethin...
Say, I have a code file where all the core logic is located. In addition, I have some custom logic that is defined by some flags, like if (a && b && c) {} if (!e && f) {} else if(d && c) {} These custom logic pieces are spread over the core logic file. In general, it runs default logic, but sometimes custom. I find i...
I'm looking for a good way to somehow dynamically inject several objects to main class and adjust its method by calls of these dependencies, e.g. ComponentClass1 { updateSmth1(); }; ComponentClass2 { updateSmth2(); }; ... ComponentClassN { updateSmthN(); }; And for now I need to change ctor and update method ...
We have a method called attachDevice(Device device) which has only one argument. We had a situation to overload this method with one more parameter as like attachDevice(Device device, String deviceName). with single argument public void attachDevice(Device device) { .. .. } with double arguments pub...
I am writing a web Job that will process messages from Azure Topic Subscriptions. Each message received by the Topic may need additional processing and the Topic Subscription Filters will contain the logic to determine this. The messages that are placed in to a Subscription will then be processed by the Web Job. I am ...
I'm digging into background audio playing for iOS Apps. I do see a bunch of examples for doing continuous audio playing for background Apps. I wanted to add walkie-talkie like features to my current App, which would need the following: The App is able to access sockets in the background to establish a constant connexi...
In a module (file) I organize several functions related to a specific domain task. I usually put the function linearly from top to bottom, then compose a functional call on the bottom. Doing so I can easily follow the flow on what's happening. But when I put in a reusable function, it 'breaks' the pure flow as several...
I work with a site that employs a site search feature for its users. Before working on this site, I'd come to expect GET-style results with a parameter like "/search?q=entrepreneur" or POST-style results without a parameter like "/careersection/10000/jobsearch.ftl" This site works a third way that I don't understand, y...
Basically I am designing a web-enabled application that should have an API in the middle. I found this question on Stack Overflow, which unfortunately has no answers. Let's say there is a system, similar to this picture: The center "API" is basically an HTTP server written with one of the RESTful frameworks in some l...
Suppose I have an object which has a point denoting it's location and shape. type Point = (Double, Double) data Object = Object { location :: Point , shape :: Shape } where a shape might be like data Shape = Circle { radius :: Double } | Rectangle { height :: Double, width :: Double } Suppo...
I have a bunch of controls including labels, updown menu, combo boxes, radio buttons, and check boxes that must be replicated once someone hits the add button. Is there a way that I can create a layout with all of these and just replicate the layout, itself?
If I wanted to turn a Java game into Lua, how could I do it? I'm thinking that you could have a program read the assembly language behind two programming languages, find the patterns, attach them to functions, and then convert the code accordingly. Has it been done, attempted, or theorized? What would be required to ac...
NOTE : Feel free to edit the title if it is somewhat different than my question. In one of our application, we are maintaining a lot of properties inside Instance object. Obviously it's maintained as Map<K, Map...>. There are few instance objects which holds different types of properties. For example 1) AppPropertyRead...
I have a Texas Instruments development board: LAUNCHXL-F28027. I'm confused on the difference between SPI (Serial Peripheral Interface) and SCI (Serial Communications Interface). What are their differences and where do they overlap as functionality? My goal is to make a bidirectional communication with the PC via USB.
I'm working on a component where I put in data and I get different data as a result. The input is always the same (3 Objects). From these 3 Objects up to 9 other Objects can be calculated. One calculation for each output Object is performed. Before the output data is calculated I want to set which of the 9 Objects sha...
I would like to acheive the following with AGPL and wondered if it is possible: release an open source software product where everyone can share and contribute free for non-profit charge "commercial/for profit" customers for using the product in their staging and production environment only while all other environmen...
My Microprocessor class instructor gave us an assignment and said: "Write an Assembler in C." - My beloved Professor So it seemed a little bit illogical to me. If I'm not wrong Assembly Language is the first step from Machine Code to the journey of higher level languages. I mean C is a higher level language than Asse...
I dont want to put too much code so I'll just put the code that involves recursion. This algorithm is fairly well known so I think everybody knows the basic code. void mergeSort(int array[], int l, int r) { if (l < r) { int m = l + (r - l) / 2; mergeSort(array,l,m); mergeSort(array,m+1...
Problem: How to edit a master copy of a document and push changes to a large (approx. 1000) number of individually personalized documents without overwriting all personal changes? Example: "Hello World" is changed to "Hello World!" which would need to change "Hello_World" "Hello World" "Hello World" to the followi...
I am old to programming and very beginner to Machine Learning and what make me surprise is the defination as i typed in google i found this. Machine learning is a type of artificial intelligence (AI) that provides computers with the ability to learn without being explicitly programmed. Machine learning focuses on ...
I am building a file manager web UI (front end ReactJS, back end Flask). RESTful API seems to be very suitable in this situation at first sight, but I get into trouble. I need API contain: List Operation: get all path info under a folder(path), like ls command Delete Operation: delete path Rename Operation: rename pat...
One of my coworkers puts all the css files in o one lib.css in the end of the project. I hate it because when i need to change something its just bad the see which scribt is involved (i see its in lib.css put not if its bootstrap or whatever). I think this makes everything more complicated or is this the "right" way?
I am a Scrum Master and have been practicing Scrum in my Organisation. We have now moved on to ServiceNow for development and we are facing issues now. Issue: We work on sprint->story->task, but, we now have a requirement that my story also needs to be tested by the client (customer/stakeholder) before closing them.I a...
I do like to write code, but what I like even more is to remove code! Following the mantra "code that does not exist cannot have bugs", if we can accomplish the same result with less code, we will make our lives easier in regard to future maintenance (and I've spent a lot of hours in maintenance). In my new job, I am f...
I very often work on some features of my project that I need to take a break before it is good enough for a commit. However, I use daily two different computers to code (my laptop and my research lab desktop). E.g.: I am working on a feature at home, then I stop and go to my lab. I don't want to mix cloud syncing (e....
Do i insert the current directory files name into the database in PHP but without using the form??.. Because in my project a device send the pdf files on server's folder and i want to save these files name in database
I've been trying to learn some of the new features of ES6, and while most of it makes sense, I'm having trouble grasping the arrow function. I'm not asking so much why it exists as I am how to read it. Previously in JS, when a function was defined, the syntax reads really nicely. var foo = function(property) { return p...
I have been assigned as the lead dev of a newly formed team. I am the only person familiar with the software platform we will be using and the only person to have worked in this domain before. There are 4 other devs 2 are essentially collage grads the other 2 are mid level. I'm struggling to balance my time between pla...
This question is about coding style. Say I have a function, f. f depends on a condition C. It calls another function g as a subroutine. g also depends on condition C. If it finds condition C is not satisfied, it raises an exception. Now, in function f, should we write: try: result = g() except TheSpecificExcpetion...
I have been recently asked to prepare a network scanner for association that teaches and lectures about security in information technology (mainly pro bono). I'm thinking of putting it as an open source project on GitHub for others to benefit from it and (probably) for mentioned organization, so that others can learn c...
I have a study facebook group which has a lot of information. The size is about ~10k post and 30k comments/replies etc... making it very hard to search on facebook itself. So I am trying to dump the data to a csv file, or an sqlite database. Here's the design: The entities: The flow to download: How to update: How...
Can someone explain this code : <?php $a = 5; $a = $a + 1; echo $a; ?> The output is 6, How? what did save in RAM? $a = 5 or $a = $a + 1 ?
I work at a badly designed, overengineered project where mandatory code reviews have been introduced few months ago. I've been asked to review a substantial piece of code that implements a new feature. It bears the same flaws as the rest of our codebase. I understand that to a large degree, those flaws creep into the n...
I have my tables as below Role(Role ID, Name, Other_Columns) Command(Command ID, Name, Other_Columns) I have association table RoleCommand. Is it okay to have RoleCommand(RoleName, CommandName) instead of RoleCommand(Role ID, Command ID). I feel like it is easier to read or populate the association table in this case ...
I'm written a software as an exercise to improve my skills and I ask my self about how to test code that changes a database. Let the code in my github: https://github.com/daniloanp/Ensaios/blob/develop/application/backend/pgsql/tables/module.go What is the best technique to perform tests over, for example, the Create a...
I'm currently working on a project consisting of two different web applications. One of the applications is a PHP web server with a website front-end and a MySQL database. It consists of Laravel framework and uses Eloquent ORM to make transactions on the database. The other web application is a Java back-end server tha...
I have a table where each record has a corresponding image (say the table is users and the image is the profile image. I am saving the images in the file system. I am thinking of using the table record id as the image name, rather than having a separate column in the table for the image name. That way I can find the pr...
I just started Programming Pearls and have already gotten bent out of shape over the first question in Column 1. The problem is to sort a file with up to 10 million 7 digit elements without memory constraints. The solution is as follows: int intcomp(int *x, int *y) { return *x - *y; } int a[1000000]; int main(void) { ...
In order to prevent spaghetti code in Puppet I am applying the Roles/Profiles pattern. Now I am learning Ansible and I am concerned whether spaghetti code will occur like back in the days when I started with Puppet. What patterns could be applied in Ansible to prevent code duplication and spaghetti code?
Should we avoid multiple interface if possible? Because I think at most cases a class with multiple interfaces can be replaced with another version with composition and single interface only e.g.: multiple interface: public class C implements A,B{ @Override public void a(){ } public void b(){ } } c...
public class Factory { public INode CreateNode(TypeEnum type) { switch(type) { case TypeEnum.Document: return new DocumentNode(this); case TypeEnum.Item: return new ItemNode(); } } } public interface INode { void DoAction(); } publ...
I've recently been shown some JavaScript plugins written for OBIEE Mobile App Developer, as well as some custom libraries for various projects. Coming from an OOP background, I am a little confused about the structure of these projects. I am seeing files that are thousands of lines long. I am used to splitting things i...
Prefixing methods and members with an underscore indicates internal use. For simple classes, I sometimes find the easier reading and typing of self.foo outweighing the indent of self._foo. Especially when implementing an abstract interface, this interface is already pretty clear. Of course, the class could have more pu...
Considering that Spring framework can manage pretty everything related to object creation (life cycle, object scope ..), is it longer necessary to use singleton pattern in an application using the framework, or are there still situations when we need to use Singleton pattern instead of singleton instance created by Spr...
MVC is pretty straightforward. There is a Model, a Controller and a View. When we create a website, it all come together as 'client sends REST keyword request to server -> the server matches the requested URL to the controller action -> which then calls the model(s) for data gathering/processing, gets the result -> and...
In a JavaScript app, suppose I have a nested object like this: var myObject = { someProp: { someOtherProp: { anotherOne: { yetAnother: { myValue: "hello!" } } } } } In another part of the code, I'm calling myValue multi...
Google API key is now required for new websites even for a single map embed. How are you going to handle this? I guess the correct way should be to ask a client to create his google API key and send it to you. The first problem is that not all my client has a google account, some doesn't have one and some have a person...
I'm trying to find a way to avoid starvation in my program, a producer/consumer (two threads, one for each role) problem with four priority levels (four deques). Basically, the consumer thread always remove from the max priority deque until nothing is left, than it goes to remove to the medium priority deque, and so on...
This is a academic question, but I think only professional programmers are the people who can answer this. Is it true that whatever we can do with pointers, we can do without them as well? This is something one of my undergrad teachers mentioned and I never really cared to find out, now it seems I have to. I and anot...
tl;dr - On an existing angularjs grid library, am moving to another. Is it better to wipe out as much code as possible and in a sense code from scratch to the same featureset, or work around what's there? Is there a recommended way (or even a good idea) to try to leverage what's there? Better context: My team has inhe...
I am developing a project in C++ that deals with converting an ASCII hexadecimal string representation into binary. The class also has utilities in it for extracting info from the string. Right now my project contains ASCIIUtil.hpp/cpp and Parser.hpp/cpp and it seems to be working correctly. However, I feel like a cla...
The Scenario I have a Classic ASP project with a SQL Server backend that I need to port to ASP.NET MVC. The legacy site makes liberal use of schema definition analysis in the application itself. For example, to run a given report and let the user supply a sort order, the application will read the schema and provide a ...
Silent failure for such trivial code. How can they claim high integrity? with ada.text_io; use ada.text_io; procedure overflow is procedure p (i: positive) is x: integer := integer'last; begin x := (x+i)/2; put_line (integer'image(x) & " should be positive"); end; begin p(10); e...
I am interested in creating a specification for the representation of complex hierarchical (domain-specific) data in a way that is independent of implementation. Think of a blueprint from which you can implement classes (in your language of choice), an xml schema, database tables, a yaml structure, or whatever. The s...
Let's take a traditional functional requirement: The system shall allow the user to create an account with an email address and password A user story that covers this requirement might be: As a shopper I want to create an account so that my preferences will be retained And the acceptance criteria for this story m...
Design and implement Cash Register: Given a number of items you will be required to calculate the total bill. Items are charged for in a couple of different ways: A given price for each item, e.g. Boxes of Cheerios are $6.99 each A given price by weight, e.g. Apples are $2.49 per pound Items can go on sale where you m...
I read about this snafu: Programming bug costs Citigroup $7m after legit transactions mistaken for test data for 15 years. When the system was introduced in the mid-1990s, the program code filtered out any transactions that were given three-digit branch codes from 089 to 100 and used those prefixes for testing purpose...
This might sound similar to some of the other questions but it does not deal with wait or notify. I have two threads which do two different things The first forms a process in the background and changes behavior when it receives an input from the other thread that interacts with the user.
I'm working on an CRM type application(.NET, SQL Server) that needs to generate reports from large datasets, millions of database rows in a dozen different tables with a lot of aggregation and logic. The reports are currently generated by long, complicated stored procedures with lots of joins, temp tables and logic. ...
Here are the two cases under consideration. (a)Scalars and (b) Numpy matrices. My query is about initialization and assignment. 1 Perfect y = x = 0; x = 7 print(x,y) y = 8 print(x,y) x=10 print( x,y) output is perfectly fine. Effect of y = x = 0 is not seen. 7 0 7 8 10 8 2 Perfect import numpy as np n=3 #d11 = ...
In a regular WSGI service provider implementation there is a blocking HTTP server that services clients. When a client, for example, creates an invoice, the server simply makes a CRUD operation that creates rows in necessary tables. Then there is a worker - typically a shell script that uses the same set of models the ...
I often have a situation where I first need to do something in the UI thread (Android in this case), then to some networkstuff in an extra thread, switch back to the UI thread and udate the layout, etc. This looks most of the time like this: MainActivity.getActivity().runOnUiThread(new Runnable(){ @Override pu...
At my new job I am working on a basic existing CRUD web application in MVC + with an Angular front-end. The MVC API has a Swagger spec and it's used to generate an API client with auto rest. That API client is consumed by the front-end. Now I understand the technical implementation but I am scratching my on why this is...
I'm trying to write a simple game and I really want to finally create something that would be "programmatically correct". I stuck with a problem like this: I have class public abstract class ProjectileLogic<T> where T : ProjectileInfo{ protected T _projectileInfo; public abstract void OnInitialize(); public...
We have a conventional application built using ASP.Net Web forms which uses SQL Server for database. Reports are generated using SSRS. We have a main table called ManifestContainerDetails - this table is for reporting purpose. When shipping is done for a manifest, it’s component details will be stored in this table. Th...
Should a daemon, forked from a CGI script (whenever the CGI script is called and the daemon is not yet running), hang running (most of the time just waiting for a connection) all time, or should it be terminated as soon as there is no more data to process (to be restarted by the next CGI call)? (The process is a Perl s...
I'm quite unsure what I should use in C# - both should in theory do the same, but I think both are quite easely overseen. Or is there another possibility I have to take in consideration? I know in C++ you use copy-constructors. But in C# I have never heard much of them (they are just a ctor with self as parameter and s...
Is there any way that I can remove or add element in map I am currently iterating(using iterator) upon. Please suggest.
When auto was considered for addition to the C++ standard, was there any discussion of setting implicit types where there are no explicit declarations? And if so, was the discussion recorded anywhere? Not intended as a criticism. Just curious from a PL perspective.
I'm using some code, which uses variables declared in a loop after the loop. For example for (int i = 0; i != 10; i++) { // do stuff } int x = i; I get the "i" undefined error. Is there a compiler switch to change this (in VC++ 2015)?
There is a lot of content on the web discussing if it is worth defining an interface if only one class implements it. The answers are mostly either "Yes, because you probably need to mock it anyways" or "No, I strongly believe in YAGNI". But what about narrowing the classes public interface? Example: public interface P...
Recently, I've read a blog post, that I can't find back, about how we should "free the data". The main point of the post was that we use classes and encapsulation too much since a lot of problems can be solved with less overhead by using plain old (passive) data structure combined with function overload. The post raise...
Can I use R via RDOTNET without having to provide the source code of my application. R is covered under GNU GPLv3. RDOTNET is under New BSD. From the RDOTNET description: "R.NET enables the .NET Framework to interoperate with the R statistical language in the same process. R.NET works on Windows, Linux and MacOS." I u...
I'm developing a virtual assistant to manage transactions in a business. I'm using an external service to handle Natural Language and get intents, actions and parameters from my user requests. The client sends requests as text strings to my application logic and my application logic routes the messages to the NLP or th...
Let us consider the following C# code as an example: public static string GetCurentExecutableDirectory() { return System.IO.Path.GetFullPath( System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); } According to documentation, System.Reflection.Assembly.GetExecutingAssem...
I have in my program a class with a member function that should treat certain objects slightly differently than others. In order to do this, it needs to know which object was passed to it, because these objects would have peculiar data pointed to by their data members. But it seems that referencing the name of the invo...
I'm a very new programmer developing my first application in Java as a side project for my employer. I'm a part-time student working full-time hoping to eventually score a developer job, and my employer encouraged this by allowing me to set aside some time daily to work on it. For the sake of anonymity, we'll call my e...
So, I've been refactoring my videoconferencing application for a while, covering it with unit and general tests. Finally, I got to the point where I need to write a loopback test with 1 client sending video stream over to another client. This is not supposed to run as one process, even on the same machine. Nevertheless...
Take the following sequence of events: Business layer requests data x and y from data layer. Data layer returns version 1 of x and y. Business layer starts performing logic based on data x and y. Another (concurrent) operation updates data x to version 2. Business layer instructs data layer to save new data z based on...
I am needing some assistance with designing with DDD. I have three classes, Family, Child and event. Is the correct way to model this to to have Child in both Event and Family and make Family and Event an Aggregate Root. My question is it ok to have an Entity as a member of two AggregateRoot? public class Child: E...
I ran into an error stating: "ImportError: No module named 'pywintypes'", and after some reading around, I have discovered that the DLL for pywintypes is in C:\Python35-32\Lib\site-packages\pywin_32_system32 in the form of a DLL file. Others have suggested adding the path to system path. I am new and have no clue how ...
This question is based on two premises: First: an object must always have valid state. It is discussed in various posts, too. https://stackoverflow.com/questions/22408804/should-a-c-object-always-be-in-a-valid-state Second: a class can exclusively trust itself to anticipate as to whether its instances will have valid ...
I'm learning .net MVC while developing a simple word list - Eg. When you learn a new language and create a list of words related to a certain topic. I don't think I'm following the rules or good practices of the MVC architecture. It doesn't feel right that I pass the full Model to the view, which also contains methods...
I have to start using versioning for my project which is a web app so compatibility isn't really a problem. I think using a Major.minor.revision.build is too cumbersome. I am almost convinced to do it with just the build number. I don't care for hotfixes, feature releases, etc. This is a web app. I will never have on...
Is it okay to group several Components into a single lifeline for simplicity? For example, let's say I have a UML Component Diagram, and it's a layered architecture. There are 26 components, one on top of the other, component A to Component Z. The interface to the system is Component A and the processing is in Componen...
This is a blindspot in my understanding of REST. I understand how to make get calls (and Post) if the call is simple, and requires maybe a few parameters. Example: https:\\randomAPI\get\coats\size:12\length:8 But what if I need to update a resource, and the request calls for multiple parameters, some of which may be...