Programming

C++ How do I tell if I'm overengineering my project?

Learn Programming - Thu, 11/15/2018 - 18:58

I'm working on cleaning up a pet project of mine and I'm trying to make it as readable and professional as possible, as it's going to be a big resume item. Because I'm trying to keep it so clean, I'm worried that I'm going from poor design to designs that are far more than necessary.

For example, I'm emulating some hardware and some of the components store their own memory. I wrote a memory template class that takes one of the template parameters as the size (which is a compile-time constant). A catch, however, is that the memory can be 'mirrored' in certain locations such that an access at address 0x1000 actually just reads 0x0000. To overcome this, I've added more template parameters to specify a mirroring region, and the size of each section that's mirrored.

template <int size, uint16_t... ranges> class Memory { public: inline uint8_t Read(const uint16_t& address) { // Implementation.... };

Then to specify the ranges, I have a header with just this

namespace CPU { constexpr int MemSize = 0x10000U; constexpr uint16_t RAMMirrorLow = 0x0000U; constexpr uint16_t RAMMirrorHigh = 0x2000U; constexpr uint16_t RAMMirrorSize = 0x0800U; constexpr uint16_t PPUMirrorLow = 0x2000U; constexpr uint16_t PPUMirrorHigh = 0x4000U; constexpr uint16_t PPUMirrorSize = 0x08U; typedef Memory<MemSize, RAMMirrorLow, RAMMirrorHigh, RAMMirrorSize, PPUMirrorLow, PPUMirrorHigh, PPUMirrorSize> CPUMemory; }

And then in my CPU class I just have

CPUMemory mem_;

as a member.

Is this too much?

submitted by /u/girandsamich
[link] [comments]

Benefits of headers or is it ancient?

Learn Programming - Thu, 11/15/2018 - 18:36

C and C++ have header files to write declarations of the implementation.

Newer programming languages have both the declarations and implementation in one source file. Rust is a systems programming language and i dont think it has header files.

Is there still a benefit of the c/c++ approach of having header files for a programming language/compiler design? Or is it considered ancient in 2018 and only unchanged for backwards compatibility?

submitted by /u/silentcon
[link] [comments]

[advice] 3d skeleton tracking into 2d physical drawing

Learn Programming - Thu, 11/15/2018 - 18:27

For a college assignment (collab),

1) we want to let children draw themself.

2) record a dance (skeleton 3d tracking)

and map the dance on their drawing. (dancing drawing)

On the sheet of paper, we would put dots (stickfigure) for an easier recognition of their drawing.

We think kinect is the best solution for body tracking or are there better alternatives? I was also wondering if we could work with Spark AR Studio (full body tracking?).

The assignment goal is to explore technologies you didn't use yet. Any advice is welcome for our codeplan,
thank you!

submitted by /u/PaintingPuma
[link] [comments]

Any Python modules for making animated pop ups?

Learn Programming - Thu, 11/15/2018 - 18:26

You can make pop ups very easily using PySimpleGUI, but you can't animate them. Imagine those antivirus popups that slide up in the bottom right of your screen; how might I make one of those?

Any ideas are appreciated!

submitted by /u/SengokuHop
[link] [comments]

How to create a String from two sets in Java?

Learn Programming - Thu, 11/15/2018 - 18:22

Hello guys!I have the following question.I have to represent a Teacher by a String that goes as follows("NAME" + "ID" + "COURSE1" + "DISCIPLINE1" + .. + "COURSEN" + "DISCIPLINEN");My Courses and disciplines cannot be duplicate, so they are stored in a Set.

A discipline is only connected to one Course. A Course can have multiple disciplines.When representing the teacher, I have to sort my Courses in alphabetical order and then my Disciplines from inside the Course in alphabetical order too.

My current implementation is only returning the first part and I don't understand why.I'm inside the class Teacher

public String complexToString(){
String firstLine = this.toString();
String finalString = firstLine;
List<String> listOfStrings = new ArrayList<>();
for(Discipline d : _teacherDisciplineSet){
listOfStrings.add((d.getCourse().getName() + "-" + d.getName()));
}
Set<String> mySet =
listOfStrings.stream().collect(Collectors.toSet());
for(String s: mySet)finalString += s;
return finalString;}

submitted by /u/stefanopro
[link] [comments]

Can you tell me where a good Java tutorial is?

Learn Programming - Thu, 11/15/2018 - 18:21

Can you tell me where a good Java tutorial is? I want to learn to create mods and learn java period but I can never find one that is detailed and has good reviews. Also I would like them to teach it inside intellij idea.

submitted by /u/redditupheld
[link] [comments]

PyCharm - I am able to use a package in the shell, but when I import it in my editor (my .py file) it's not recognized

Learn Programming - Thu, 11/15/2018 - 18:15

I'm working in PyCharm, sorry that I don't have the correct terminology for these things.

When I'm editing my .py file and I try and do: import PySimpleGUI, I get the error saying "No module named PySimpleGUI".

However when I use the Python shell embedded into PyCharm and run "import PySimpleGUI", I can import it just fine and use the methods associated with it.

Note that I installed the module through the cmd embedded into PyCharm, using the command pip install --upgrade PySimpleGUI. When I run pip list, I see PySimpleGUI on the list.

Does anyone know what is wrong? I'm on Win10 if that makes a difference. Any help is appreciated!

submitted by /u/MyosinxActin
[link] [comments]

C Programming Matrix values getting corrupted??

Learn Programming - Thu, 11/15/2018 - 18:09
#include <stdlib.h> #include <stdio.h> int main() { int rows, columns, i, j, k, n; int matrix[10][20]; printf("Enter number of rows "); scanf("%d", &rows); printf("Enter number of columns "); scanf("%d", &columns); for(i=1; i<rows+1; i++) { for(j=1; j<columns+1; j++) { for(k=1;k<=1;k++) { n = rand() % 10; n = matrix[i][j]; } } } for(i=1; i<rows+1; i++) { for(j=1; j<columns+1; j++) { printf("%d\t", matrix[i][j]); } printf("\n"); } }

It keeps returning some random numbers like 35769 or some bs like that. Help? The matrix is supposed to fill with random numbers from 0-9 and be printed. Number of rows and columns specified by user.

submitted by /u/epicboyxp
[link] [comments]

Tutorial: Make a Real-Time Chat App with Action Cable & React

Learn Programming - Thu, 11/15/2018 - 18:02

Hey all,

For those who aren't familiar, React is a popular JS framework and Action Cable integrates WebSockets into a Rails app. To quote the RoR guide, Action Cable:

"...allows for real-time features to be written in Ruby in the same style and form as the rest of your Rails application, while still being performant and scalable. It's a full-stack offering that provides both a client-side JavaScript framework and a server-side Ruby framework. You have access to your full domain model written with Active Record or your ORM of choice."

Learn how to create your own chat app

submitted by /u/Chamber_s
[link] [comments]

What is "pip install --upgrade x" used for?

Learn Programming - Thu, 11/15/2018 - 18:02

I've looked at the documentation (I Ctrl+F'ed the word "upgrade" but it didn't really clear anything up) here: https://pip.pypa.io/en/stable/user_guide/#only-if-needed-recursive-upgrade

but I still don't quite get it. What's the different between doing "pip install x" and "pip install --upgrade x" (where x is the name of a package) ?

I'm asking because a package I want (specifically, PySimpleGUI) tells me to install the package using pip install --upgrade x instead of just pip install.

submitted by /u/SengokuHop
[link] [comments]

Why is there a terminal in PyCharm (and other Python IDEs) which resembles a Linux terminal and lets you use Linux-like commands? What exactly is it?

Learn Programming - Thu, 11/15/2018 - 17:51

Is PyCharm and any other IDE that has this feature just emulating Linux to a degree to allow you to use commands on your code/projects more easily? If so, which distribution are they emulating, seeing as commands can be different depending on the distribution. And is there a better explanation for what this is (I feel like I'm missing something)?

For example, using pip commands feels extremely similar to using commands on Linux (I'm a Python as well as Linux newbie though so I could be wrong. pip is also the only command I've ever used within this in-app terminal)

One side question I have is: which project does this terminal apply to? I've read that when you download a module using pip, it's only downloaded for your specific project instead of system wide. But my terminal doesn't seem to care which project I'm currently working on.

Any help is appreciated!

submitted by /u/SengokuHop
[link] [comments]

Anyone knows why bootstrap 4 used 1rem = 16px when they were using 1rem=10px in bootstrap3?

Learn Programming - Thu, 11/15/2018 - 17:50

Isn't 1rem = 10px recommended one, since it eases calculations? Also if someone is using bootstrap, they can't change 1rem to anything else. So I am kinda confused over the decision.

submitted by /u/sangupta637
[link] [comments]

Where are Python modules installed and how can I delete ones I don't use anymore (I'm using PyCharm)?

Learn Programming - Thu, 11/15/2018 - 17:33

I use the CLI in PyCharm (the one that resembles a Linux terminal) to install my modules, but I'm wondering where these are actually being installed. I'm also wondering if there's a command I can run to list all the modules I have installed, as well as delete certain modules (just so I can stay organized).

Any help is appreciated!

submitted by /u/SengokuHop
[link] [comments]

I want to learn python

Learn Programming - Thu, 11/15/2018 - 17:28

Does anyone know any websites to learn python for finance purposes?

submitted by /u/Glenalbania
[link] [comments]

What are some fun ways to use a linked list in a program?

Learn Programming - Thu, 11/15/2018 - 17:23

I have an assignment to make a generic linked list, and create a driver program to show it off. What are some things that a linked list would be good for in the real world? The textbook is very theory based and I have no idea what simple uses for a linked list are.

I'm not trying to make this a huge project, just trying to make the program somewhat meaningful or interesting.

submitted by /u/DjStarfruit
[link] [comments]

Beginner looking for help on basic Oregon Trail Game

Learn Programming - Thu, 11/15/2018 - 17:19

Hello! So I'm currently assigned the task of programming a simple version of the Oregon Trail in c++. The problem I am currently having is thinking of 4 user defined classes which I can use (as it is a requirement to make 4 classes). Brief summary of my simplified game: 5 people (each you assign names, each has their own health bar) leave at a preset date and travel the trail. The player is prompted to go to the store at the beginning to purchase food, oxen, bullets, wagonparts, and medkits. After this, the game starts. Before each turn, a status update comes up showing the date, miles traveled, food, bullets, and cash the party has. During each turn, the player can choose to rest, continue on the jurney, or hunt for food. After each round a player has a chance to encounter a misfortune (getting sick, oxen dying, wagon breaking, etc. 40% chance of happening each time), or encounter a raider attack (really weird long equation they've given me, you can run attack, or surrender). When hunting, a puzzle function will be used to determine whether or not you get a kill, and this same function will be used when deteremining whether or not you win the raider attacks. I just need to make 4 classes for the game! Thinking of a player class (holds health, names, etc.), but can't think of anything else. Any help would be appreciated! Thanks

submitted by /u/SaborFlash
[link] [comments]

What Is The Best Way To Make Buttons In Pygame:Python

Learn Programming - Thu, 11/15/2018 - 17:15

So I'm Just Asking What Is The Best Way To Make Buttons In Pygame:Python

submitted by /u/8_BIT-DEV
[link] [comments]

options ng-repeat not working at all but I fully expect it to...???

Learn Programming - Thu, 11/15/2018 - 17:14

I've read many links online and expect this code to work but it still shows an empty box.

<select ng-model="dataPortal.dataPortalForm.messageNumbers" style="width: 300px;"> <option ng-repeat = "messageSummary.messageNumber in messageSummaries" value = "{{messageSummary.messageNumber}}"> {{messageSummary.messageNumber}} </option> </select>

I also use messageSummary.messageNumber in the same html file but a diff tab and it works fine there by printing it in a table column.

Here, it just shows a empty drop down box.

Any help? Thanks in advance. Appreciate it.

submitted by /u/DoctorQuinlan
[link] [comments]

Pages