instruction stringlengths 34 36.1k |
|---|
I'm trying to build a strong AI for a game called Puyo Puyo, in Matlab (I know... but it's the only language I know well).
Basically it's like Tetris but you get falling pairs of 2 puyos (blobs) of different (or same) color, among 4 possible colors. You can move them around and place them however you like. Fill the scr... |
I'm working with a library (from an online source, not authored in-house) providing an interface as well as an implementation of it:
interface FooInterface {
// ...
}
class Foo implements FooInterface {
// ...
}
I'm not satisfied with the default implementation, Foo, so I can always write something like:
class M... |
In my databases, I tend to get into the habit of having an auto-incrementing integer primary key with the name id for every table I make so that I have a unique lookup for any particular row.
Is this considered a bad idea? Are there any drawbacks to doing it this way? Sometimes I'll have multiple indices like id, profi... |
I am making a program that primarily deals with heavy data mining and analysis. It is primarily a back-end type algorithm, with no GUI elements or console windows seen as it runs. Occasionally though, it will need to graph something or get very special input from the user. However, I initially didn't want to build the ... |
I want to create some clans in my game... And they can have some admins with some privileges...
Am I need to create 2 tables one of them for clan info and one of them for clan members ?
|
I had the impression that "front end" refers to the user interface in most cases, but occasionally people also refer to "the front end of a compiler". So what is the difference between these two terms?
|
My company manages a lot of web sites, and we are currently working without a VCS. I want to propose a VCS for a few reasons, but I think our requirements may be too unique. We work off of a shared drive that is mapped to windows explorer that has a mirror for each site. When edits are made they get pushed to staging, ... |
I'm learning PHP, and I accidentally forgot the parenthesis in Echo 'Example'
I'm curious as to why this worked, the only time I've seen this allowed was in SML, where the reason was that "All functions take only one item as a parameter, and that can be a tuple (A grouping of values)"
Is it similar to that reason? Or s... |
I have the following resources in my Asp.net web API:
route: consisting of the following relevant properties
arrival_location_id
leaving_location_id
and location:
id
name
coordinates
The thing is, When I create a new route, I create many routes and I want to allow users to create a new locations if they don't alrea... |
I'm writing a REST service with Web Api. One of the actions reads an AppSetting value from the web.config during execution.
I would assume the web.config is loaded into memory, but during high load, does reading the setting have a noticeable performance impact? What are the best practices for doing this?
|
Sometimes when you're coding you're on a problem which can be solved with some recursive method. What is for you the best way to detect when the recursion is a good way to solve a problem and how to implement it efficiently?
I mean, how do you visualize it? How do you convince yourself that it works?
|
I am facing tough time deciding on whether to have two different classes in system, one for keeping class invariant and other for (de/)serialization or to just have a single class which does both.
The project I'm working on is in Java and for (de/)serialization I am using Jackson mappings.
Pros of Keeping 2 classes:
M... |
While there are/were several languages with dependent types, like Agda, Coq or Epigram, none seemed to gain wider adoption. Despite that dependent types allow very strong type safety, up to writing complete program specifications. Did anyone analyze what are the main blockers for such languages to become more mainstre... |
When designing a system that displays information about an entity (but where modification of the data is rare or restricted to few users - such as a user profile), would it make sense to have two separate classes to do this?
One for management of a user profile (logging in, changing password, modifying profile content)... |
I am writing a "hunting-ground" application in Java. I planned the hierarchy of classes as follows:
Animal.java
public interface Animal {
void age();
void reproduce();
boolean isAlive();
void die();
}
Carnivorus.java
public abstract class Carnivorus implements Animal {
double age;
double e... |
One of the most basic and widely accepted principles of software development is DRY (don't repeat yourself). It is also clear that most software projects require some kind of management.
Now what are the tasks that are easy to manage (estimate, schedule, control)? Right, repetitive tasks, exactly the tasks that should ... |
High-level explanation
I have an object with some methods:
public class Foo
{
public void Bar() { }
public void Baz() { }
}
These methods cannot be executed unconditionally, there is some validation to be done. I'd also like to expose these conditions to a client (user) in some way.
I could do this with a coll... |
Is there a preferred practice around initialising variables which are first defined within a branch of code, or is this purely subjective / personal preference?
i.e. there are multiple ways this can be done; the most obvious of which are below:
#option 1
[string]$path = ''
if ($ENV:PROCESSOR_ARCHITECTURE -like '*64') {... |
I have an excel like table with a should value and an is value for each day of a month:
descrip. | | 01 | 02 | 03 | 04 |
_______________________________________
column 1 | should | 60 | 0 | 60 | 0 |
| is | 60 | 0 | 60 | 60 |
_______________________________________
column 2 | should | 0 | 15 | 0... |
The problem is quite simple really. I'm trying to create a site, where the user can add a physical device to a database. Every device has its own unique id, which is stored in the database.
However, I want to make sure, that whoever types in the device id actually has access to the device, so that someone can't just ... |
I found this same code here:
https://stackoverflow.com/a/5854862/257299
struct Base { virtual Base& operator+=(int) = 0; };
struct X : Base
{
X(int n) : n_(n) { }
X& operator+=(int n) { n_ += n; return *this; }
int n_;
};
struct Y : Base
{
Y(double n) : n_(n) { }
Y& operator+=(int n) { n_ += n; re... |
I'm looking for a way to organize database tables when it comes to handling product option pricing retrieval and also storing pricing history for my use case.
What I have
I have a custom-made product that has various product options and belongs to a product category. I want to be able to query current price for produc... |
I have the following circular dependency that I'd like to eliminate. I think I must have a flaw in my design. And I'd much appreciate any feedback on how to fix this.
My circular dependency comes from 3 important classes. Worker, WorkingContext, and TaskManager.
First, I have 2 Worker classes (Worker, and WorkerGroup)... |
I know really good, but dead project (https://github.com/lusis/lua-httpclient), with some pull requests (bug fixes). Repo owner doesn't look at this requests, last commit was at 2014. I want full version, with all bugfixes.
What is correct action in this situation? I'm aready have got fork with bugfix.
|
I have just stepped into the Domain Driven Design paradigm but I have one question:
How is an MVVM Model different from a DDD Entity? What are the differences between these two?
|
The bottom of the Wikipedia "talk" page says that Microdata is dead, and superseded by rdfa and json-ld.
What is the difference between the formats (or value), and which one should be used?
I'm mostly interested in SEO for Google Shopping, and contact sharing.
|
I'm working with a client that only loves Wordpress, so I have to create a theme. The idea of my client is to have an interactive background (meaning there's no other content but the background, the menu and the company logo) which creates a water effect, that's already done.
Now, he wants the content to be loaded in ... |
When following Domain-driven design (DDD), is it correct for a root aggregate to hold a reference to an internal entity that happens to be the root entity on a separate aggregate?
I believe this is not correct, mainly because of this rule on the blue book:
Nothing outside the AGGREGATE boundary can hold a reference to... |
I may look like a total idiot with such a question but nothing came up when I searched it, so I guess why not. Here is my problem:
I'm doing the UML work for a C++ game, that will feature animals and races.
First, I have one abstract class Entity, and three inherited classes Human, Dog, and Cat.
Now let's say I want ... |
I would like to know how I should update many-to-many relationships in my API.
My app has companies that can have many tools and technologies. The relationship is stored in joining tables companies_technologies and companies_tools.
The frontend has a form to edit the company. I would like the users to submit a single f... |
Okay so I work on a server application that has multiple communication methods. Including but not limited to WCF, TCP and RESTFUL. These all share information with clients but recently we have been running into issues due to too many clients accessing data. This causes a delay and although we cache as much as we can we... |
When you sleep a thread, what is actually going on?
I see that sleeping a thread "pauses the current thread for a given period of time". But just how does it work?
According to How Thread.sleep() works internally and How does Thread.sleep really work?:
the sleep duration will be subject to some system-specific granula... |
I am a member of a small team which is part of a larger team of developers working with Git. We (the larger team) have a main branch in a central repository into which we commit our work for the next release (let's call it 1.0).
The smaller team has been tasked with developing a feature (upgrading an existing one, actu... |
Im writting a web-page in Ruby on Rails , so i can learn the language and framework better.
I have a User model which has_many Classifieds models which has_many Photos which accept_attachment :image.
So the whole thing works fine , the User creates the Classified , adds details and photos . User model and Classifieds m... |
If I have all my business logic in code and make use of Entity Framework, in what situations (if any) would I be better moving some business logic to a stored procedure, instead of keeping it all in code?
To be clear, I mean in conjunction with the current setup (business logic in code), not instead of. I have seen a n... |
I have WinForms GUI application, which can work in two "states" with different functionality, but these states share GUI controls. I am dividing these states by using enum almost in every method, like:
private void picBox_MouseDown(object sender, MouseEventArgs e)
{
if (picBox.Image == null)
... |
Voyager 1 reached interstellar space in August 2012 and is the most distant human-made object in existence. Launched just shortly after its twin spacecraft, Voyager 2, in 1977, Voyager 1 explored the Jovian and Saturnian systems discovering new moons, active volcanoes and a wealth of data about the outer solar system. ... |
I'm currently assigned a task, where I have to program a bidirectional synchronisation between 2 ERP-related software, one providing webservices (Visual Studio Web Reference) and the other one providing a REST API.
I managed to match the fields of the APIs together, so I could potentially start creating objects in both... |
Building a UI editor for Android and basically there are interfaces such as this:
interface Item {
fun decorate()
fun translate(x: Int, y: Int)
fun rotate(rotation: Float)
fun scale(scale: Float)
fun select(value: Boolean)
}
also has been extended with interfaces like so:
interface Removable {
... |
I have N strings and M search-replace pairs. Each of the strings contains exactly one of the search pair and the whole string needs to be replaced by the replace pair.
Say you have returns,between,paragraphs and turn => foo, tween => bar, rag => baz then your output is foo, bar, baz.
N can be a real big number while M ... |
As said in the title, which data type should a lexer return/give the parser? When reading the lexical analysis article that Wikipedia has, it stated that:
In computer science, lexical analysis is the process of converting a sequence of characters (such as in a computer program or web page) into a sequence of tokens (s... |
In scaled Scrum release management, what's the code management strategy if there are unfinished features in the code base?
For example, SAFe agile framework recommends all teams complete sprints the same day (they run on the same cadence).
Say all the teams are preparing for a release --- they all meet their sprint go... |
I'm trying to avoid casting of any type. I have the following simple Bus class that you can use to register your handlers:
public interface IDomainEvent {}
public class Bus
{
private static readonly IList<IHandler<IDomainEvent>> Handlers = new List<IHandler<IDomainEvent>>();
public static void Register(IHandl... |
I'm strongly considering a web search engine for my next pet project. All the basic principles are clear, but some details are not. Namely, I can't find a neat way to search by exact match, e. g. "The Who".
This requirement imposes limitations on how I can modify the source text:
I can't use a list of stop words (h... |
I've been using various server side languages/frameworks for developing back-end web applications. Every server-side framework that I've been using has the capability for returning views/templates (whole or part of a HTML page) as well as returning JSON responses which will then be interpreted by some front end JS.
I ... |
Just wanted to hear opinions on this kind of project structure in java for one DDD project:
com.some.namespace
application
services = (app services that talk to repositories and domain model)
validators = (validators for DTOs in app service layer)
domain
events = (domain events)
exceptions = (except... |
I believe C is a good language to learn the principles behind programming. What do you stand to learn in lower level languages that are "magicked" away from high level ones, such as Ruby?
|
I have a C# cmdlet(1) that uses "ConfigurationManager.AppSettings" to get database connection strings necessary for some stored procedures used in the cmdlet(1). If another application instantiates an instance of the cmdlet(1) class object, then calls a method on the class that use a stored procedure an error is thrown... |
I host my own webserver through Java. The problem is I can only access it through a web browser by using an ip address. Can I spoof a url? For example, I type in 192.168.2.111 into the address bar, I want this to switch to a url.
|
I would like to know if I am correctly eager loading nested resources in my API.
In my app, companies can have many technologies, and tools. The relationship is stored in the join tables companies_technologies and companies_tools.
At an endpoint /companies, I would like to return all the companies and their technologie... |
The problem: 50 different commands which are typed into a command line for a program, lets say for telling a robot what to do. Some of the commands have user determined values such as travel north 5 (5 units of predetermined kind). Others are simple commands, scan area, that have no user determined input.
In my courses... |
I'm working on developing a simple game and am using the switch statement quite frequently. Is it possible to reference the specific case in question instead of typing out the constant value? For instance:
switch(String upgrade)
{
case(Bullet_Power_1):
remainingUpgrades.Remove("Bullet_Power_1");
... |
Input data: a grid of cells of different colors.
Problem: how do I cover this grid with a minimal number of non-overlapping rectangles so each rectangle contains the cells of one color only?
|
Delegates and delegation exist to enable passing specific messages to an observer, regardless of that observer's type. In a coordinator-type architecture, where coordinators manage and run the flow of an application (instead of say the UI layer, à la iOS & UIKit), delegation serves as the primary means of communication... |
Lets say I have a Widget class. I also have TextWidget, ComboWidget, ChoiceWidget classes that inherited from Widget class.
I create this widgets based on the situation. After creating the widget, I just show some data on widget and get one from the user. After that the widget gets destroyed. My current code is somethi... |
I am trying to devise a versioning system for a product that we are building. We have three environments: DEV, TEST and PROD.
One system is that eg. if we have a (small) change in DEV, we increment the version to 5.1.2 from 5.1.1, have this version number propagate to TEST and PROD as well. Then for the next (small) ch... |
Is it possible to create a Javascript file that act as "click counter"?
What I want to do is that I put that Javascript file in my domain
mydomain.com/js/clickcounter.js
And anyone can include it to start counting clicks..
Example for THEIRdomain.com/index.html
<script src="mydomain.com/js/clickcounter.js"></script> ... |
I am trying to implement a tree data structure that callers of my code edit for me to operate on. The idea is that the caller can hold a reference to nodes from the tree and modify their data (both attributes and children), which triggers an event that prompts my code to update a visual render of the tree.
The problem ... |
We are currently working on a micro-service based system. The idea behind it is to split our monolithic system to small domains (micro-service per domain).
All services will be used by our internal applications, but we have plans to expose it to public.
One of the services would be identity management service, which wo... |
I'm a long-time Java developer who's trying to make up his own mind about TDD.
I've used JUnit since I first discovered it in 1998. I use it regularly, but I don't subscribe to "write the test first". My coverage will range from 60-90%; I'm not compulsive about driving it to 100% in every case.
I read Extreme Program... |
I'm using a large and complex library including R and C++ code, available online via a subversion repository. Trying to figure out how it works I took a bunch of notes in the source code itself, in the form of comments. Years later, the repo has been updated, so now I have to choose among:
Updating and starting from ... |
Unfortunately, I am not even sure of the keywords to use for this question, so if this has already been asked please point me the right way.
Given a set of vectors:
[3, 5, 3]
[10, 23, 5]
[123, 53, 97]
(here, 'vector' means one dimensional sets of numeric values).
I'd like to know a way of finding the closest match for... |
Synopsis:
I am working on a level editor for a game written using Unity, the game is actually a new engine for an old game. This is a +20 years old game and its data structures are by today standards, hard to deal with in an environment such as Unity. Hence why I'm writing a level editor to ease the pain.
Basically the... |
Is it good practice to use a free website as package identifier if I do not have a real website? EG com.weebly.vikarjramun.myapp.myactivity Just wondering...
|
It seems to be the view and controllers are rigidly defined, but the model is highly nebulous. For instance, views go in views folder, controllers have the word controller in their name and have controller annotation, but models...?
What is the standard or de facto or at least the recommended way of implementing the mo... |
We are about designing microservices application around REST API. The application is aimed to search, Create, Update and retrieve document from many heterogeneous repositories.
I'm wondering if I have to model the services around operations (each operation GET, PUT, POST, PATCH, ... as service) or around the repositori... |
Evans introduces in his book "Domain Driven Design" in Chapter 6 "Aggregates" the concept of Aggregates. He further defines rules to translate that concept into an implementation (Evans 2009, pp. 128-129):
The root ENTITY can hand references to the internal ENTITIES to other objects, but those objects can use them onl... |
I bet I'm not the only one here that has had problems with something like this: you want to check something in a language that has the == operator for checking equality and instead you do something like: if (a=5) which always returns true, given that the language uses = for assignation (which the most common thing by f... |
I'm lead on a team with a half-dozen senior engineers. I very much believe it would benefit us greatly to do code reviews for all the standard reasons. Not necessarily every change but at least a steady stream of background reviews. So people at least see other's changes and start talking about them.
Is there a good wa... |
I have applied a custom heuristic to my A* search. It is admissible, but it is not consistent (monotonic). As such, I am not guaranteed to find the shortest path.
I had assumed I could use a hybrid approach that calculates both the euclidian distance heuristic and my custom heuristic and choses the tightest consistent ... |
In a textbook I've been looking through for a class, it is stated, a statement can be empty (the null statement). The null statement is defined as just a semicolon.
It does absolutely nothing at execution time. The null statement is rarely used.
As a moderately experienced programmer, I find it interesting that they sa... |
Which way is better?
-- Option 1-------------
if ( condition1 )
{
statement1
}
else
{
exit program
}
if ( condition2 )
{
statement2
}
else
{
exit program
}
----Option 2------
if ( condition1 )
{
statement 1
if ( condition2 )
{
statement2
}
else
... |
I'm working on a Spring-based REST api that has v1 and v2 variants:
/api/v1/dates
/api/v2/dates
Correspondingly, there are v1 and v2 packages in the code base:
com.company.api.v1
com.company.api.v2
Is it a good practice to postfix class names with version number like below:
DatesControllerV1.java (in v1 package)
Dat... |
I have an asychronous file transfer using boost::asio.
Multiple files can be transfered at the 'same time'. Same time as in - file packet for file 1, next packet for file 3, next for file 2, ... No threaded file-transfer in the same socket.
Currently I'm sending each time a 10KB packet/message/string, including a small... |
Let's say you have a signature like so:
public void MyFooBar(IExtraSuperLongTypeName param1, TypeA param2 ISomeotherReallyLongTypeName param3, TypeB param4, TypeC param5)
Formatting in on one line is ugly and hard to read. A style that resharper uses
to format this is to push the parameters down like so
public void My... |
I am developing an Angular SPA and I am currently in the design phase. I have created a sample architecture which I am planing to use in my SPA but I would get some feedback because I want the architecture to be scalable and maintainable. I have tested this architecture out and it works so far.
My Current Architecture:... |
For some time now, I have searched and read a lot about memory alignment, how it works and how to use it. The most relevant article I have found so far is this one.
But even with that I still have some questions about it:
Except in embedded system, we often have huge chunks of memory in our computers that make memory ... |
We're actually naming our test packages just like their to-test counterparts. So we end up with this structure:
src/main/java
com.hello.world
helloWorld.java
src/test/java
com.hello.world
helloWorldTest.java
I always felt like this is not pretty smart since you can't distinguish between "test"... |
We plan to refactor our company system into a micro-service based system. This micro-services will be used by our own internal company applications and by 3rd party partners if needed. One for booking, one for products etc.
We are unsure how to handle roles and scopes. The idea is to create 3 basic user roles such as A... |
I taught a course years ago, and then I used some JDBC exercises using what I now know is the Active Record Pattern.
I would like to modernize the exercise by changing the Active Record Pattern so classes don't do their own persistence. But I would not like to use any persistence or ORM framework for teaching purposes... |
A lot of ORM sites and SQL tutorials mention these relationships as if they are obvious or to be taken for granted, but I don't fully understand why the distinctions need to be made.
Consider two tables A and B, both with id fields, and linkage(s) between these two tables.
My understanding is that:
One-to-one relation... |
I would like to use command / handler approach where I register few handlers in global.asax in my MVC app and send commands from MVC controllers to those handlers.
public class CommandProcessor
{
private static readonly ConcurrentDictionary<Type, Type> ListOfHandlers = new ConcurrentDictionary<Type, Type>();
p... |
I'm working on a smallish voting webapp. Similar to strawpoll but only authenticated users are allowed to make polls, while everyone is allowed to vote.
User:
id
email/password_hash/name/...some other data...
Poll:
id
user_id REFERENCES User.id - notes which user created the poll
title
PollOptions:
id
text
poll_id... |
I was wondering if are all tasks executed by the CPU (fetching, reading, writing, etc.)? Everything is controlled, manipulated or executed by the CPU?
|
I've been working with javascript for the past 4 years. I'm very confident about my problem solving skills and I can see that my code quality is improving. I try to stay up to date with the community and I'm currently working with ES2015 and React.js. However, I feel like I can't grasp programming design patterns at al... |
We are developing a series of tools for our internal usage (only). We are writing the documentation in parallel with the development progress.
Is it important to provide different documentation formats? For the moment we generate the documentation only in HTML
|
If we have Table A that has a one to one relationship with Table B, does it ever make sense to keep them apart? Or does it never hurt to combine them into a single table? Do either of these scenarios (two tables vs one combined table) impact anything with respect to its normal form (1NF, 2NF, 3NF, etc)?
|
I'm currently in the process of writing a program in R to perform analysis of data from a mass spectrometry experiment. Well, that's the idea. I'm fairly new to R, and didn't actually perform the mass spec experiment myself, so I'm encountering a few problems.
Essentially, I have a set of m/z (mass/charge ratio) value... |
Can using single-character variable names as parameters in a function okay?
For example, look at the code below:
public static int factorial (int x) {
if (x == 0) {
return 1;
}
return (x * factorial (x - 1));
}
In this case, is using variable name "x" okay as the parameter for the function? In wh... |
So I have a "Bars" table in my database and a "Add a Bar" form which allows a bar owner or manager to add his/her business listing to my website database. I also have a "Beers" table in my database and I want the owner/manager of the bar, when entering his/her bar info, to be able to pick how ever many beers from my da... |
I'm a junior developer learning programming in Python. I found that some of functions I write uses too many parameter, like
def f(a,b,c,d,e,g,h):
What would one recommend to avoid such a situations? I heard about classes but have not yet learned them thus far. Is it wise to make function to work like this:
def f(param... |
We're looking into adding authentication to a range of APIs that we are about to develop. The solution is entirely fluid as it currently stands, but the basic premise is that there is one API layer that the customer interfaces with, and several APIs behind that that this initial layer delegates to.
Part of the proposed... |
I am currently working on project that is make a online judging system like codeforces. In this system user can submit code and the system will compile, execute, and generate output on a specific input set, and match the output with system result then give verdict.
There is a two part of that system. Front end is in P... |
Suppose I have some project of which I own the code. It has a library which is licensed under Apache 2.0 (but that shouldn't influence this). So I can choose if I want to release the code using GPL, Apache 2.0 (or similar) or make it a closed source project.
As there is quite some code, I want to build the documentatio... |
This is a general software design question. My program is written in Java, but I suppose my question applies to any object-oriented programming language. The best way for me to explain my situation is with an example.
In applications like LibreOffice and MS Office, the user chooses a program option when launching the ... |
Let's say I have something called "Actuators". Each "Actuator" may have capabilities associated with it. Should I reuse it wherever it fits, or should I create entirely separate kinds of actuators for each kind of target?
I have block targets, I have item targets, I have entity targets and I have command targets.
An ac... |
In an off-hand comment on this question about storing PHP objects in a MySQL database I mentioned that it is probably not a good idea to do so.
My reasoning is that MySQL is explicitly a relational DBMS, and that it doesn't make sense to force it to be something else, as it will not be optimize for that.
I would assu... |
Say I have a function whose input is an array of fruit objects, and returns a list of *cloned) apples from that list, with each cloned apple mutated with an additional property visible on it. Would a good name be extractApplesAndSetVisibility, or is there a better name?
|
Why is it that :
System.out.println(+'A') //gives output as 65
System.out.println('A') //gives output as A
Also
System.out.println(8+4+'A'+"PRIME"+4+4+'A');
gives output as 77PRIME44A
Why is it that 8+4 before the String "Prime" are being added, while 4+4 after "Prime" are being printed as it is ?
I also ha... |
I've recently bumped into string methods and mainly
str()
method caught my interest because, it makes string out of every type of data?
integers, booleans and so on. And if you want, they can be easily stored in variables like new strings:
my_string = str(45161516)
that variable will automatically hold that number as... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.