• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

Anustart

Member
I'm having a hard time understanding the problem. Can you try and explain it a bit more clearly? What are the parameters? Provide the function signature, if you can.

It's this:

QGrXWjx.jpg
 

OceanBlue

Member
I'm trying to make a basic database application in C#. It's my first time with the language so I'm trying to get used to the features. It's also my first real project.

A dataset is an in-memory database right? If so, it wouldn't be worth it to make objects for your tables if you aren't going to have any specific behaviors right, since you'll just be duplicating data? I'm used to doing SQL queries in the application so datasets are confusing lol.
 

poweld

Member
It's this:

I'm assuming there's an error in the question; it states that a sub i = 0, but I believe it should read a sub 0 = 0.

Assuming that's true, here's how I might tackle it:


  1. Make a function (solve) to solve the equation for a given (k, a)
  2. Make a function (solveMin) that solves the equation for a given k using the minimum valid a. For example, if k = 3, the function should return solve(3, {0, 1, 2, 3})
  3. Loop through k values to find the largest one that is still less than T.
Now you know the maximum valid value for k, so the problem is bounded.

See if this gets you on the right track.
 
I'm trying to make a basic database application in C#. It's my first time with the language so I'm trying to get used to the features. It's also my first real project.

A dataset is an in-memory database right? If so, it wouldn't be worth it to make objects for your tables if you aren't going to have any specific behaviors right, since you'll just be duplicating data? I'm used to doing SQL queries in the application so datasets are confusing lol.

Essentially, yes that's what a dataset is. How are you planning on retrieving the data? It is certainly still possible to retrieve the data using SQL queries and populate your dataset with it. To me, the biggest benefit that objects give you in this case is that they're strongly typed, but you're free to do it however you wish.
 

CrankyJay

Banned
I'm trying to make a basic database application in C#. It's my first time with the language so I'm trying to get used to the features. It's also my first real project.

A dataset is an in-memory database right? If so, it wouldn't be worth it to make objects for your tables if you aren't going to have any specific behaviors right, since you'll just be duplicating data? I'm used to doing SQL queries in the application so datasets are confusing lol.

Depends what you want to do. If you're doing the MVVM approach this is exactly what you would be doing.

I work regularly with datasets in C#, so I may be able to help if you need more specific information.

A dataset is just a representation of the tables in SQL...you basically just need to make a SQL connection and then use a data adapter to fill the dataset.

You can make a strongly typed dataset for this if you want so you're not just making an in memory dataset (creating the columns on the fly).
 

hipbabboom

Huh? What did I say? Did I screw up again? :(
Im writing a c# .ney based background application that I need to monitor keystrokes. I'd like to do this without windows hook since that requires an unmanaged proxy all. Does anyone know a global method that reads global keypresses I can poll or an event I can register to?
 
I've graduated and I'm trying to get a job, but they all expect me to have commercial experience. I search for Graduate Developer and Junior developer, is there another word for an entry level role?
 

CrankyJay

Banned
I've graduated and I'm trying to get a job, but they all expect me to have commercial experience. I search for Graduate Developer and Junior developer, is there another word for an entry level role?

Entry level or junior level. If the job asks for 5 years or less apply anyway. You never know, they may reply.
 

hipbabboom

Huh? What did I say? Did I screw up again? :(
I've graduated and I'm trying to get a job, but they all expect me to have commercial experience. I search for Graduate Developer and Junior developer, is there another word for an entry level role?

Also remember to be sure to address the skill-set they request and offer a portfolio of your work as evidence. Being able to show demonstrable experience of the required skill can sometimes satisfy the cases where certain level of professional aptitude is required.
 

tokkun

Member
I've graduated and I'm trying to get a job, but they all expect me to have commercial experience. I search for Graduate Developer and Junior developer, is there another word for an entry level role?

Big companies often like hiring new graduates more than small companies do. Big companies have a lot of proprietary infrastructure that has to be learned, regardless of whether you are a fresh graduate or a veteran. Small companies can't afford to train people for long, so they look for people who are ready to be productive immediately.
 

OceanBlue

Member
Thanks for the simple explanations about datasets. I feel like I missed that looking through the documentation, since at first I thought the datasets were databases, so the clarification is definitely helpful.

Essentially, yes that's what a dataset is. How are you planning on retrieving the data? It is certainly still possible to retrieve the data using SQL queries and populate your dataset with it. To me, the biggest benefit that objects give you in this case is that they're strongly typed, but you're free to do it however you wish.

Depends what you want to do. If you're doing the MVVM approach this is exactly what you would be doing.

I work regularly with datasets in C#, so I may be able to help if you need more specific information.

A dataset is just a representation of the tables in SQL...you basically just need to make a SQL connection and then use a data adapter to fill the dataset.

You can make a strongly typed dataset for this if you want so you're not just making an in memory dataset (creating the columns on the fly).
I was planning on using the TableAdapters' fill() methods to populate the datasets and LINQ to access the dataset in my code. I haven't actually done it yet though. I've just been reading through the MS documentation and walkthroughs to try and figure things out, and from what I understand that's how they suggest you do it.

I might just make objects after all. Initially, I was concerned about having data stored in datasets and then copying that data into objects, but now I'm wondering if it's really worth the worrying considering this is a small personal project with a very limited scope. It's not like I'm going to have a massive amount of entries. If anything I can just wrap the LINQ in the object's methods and just give each object an index or something lol.

I don't really know much about MVVM, but from the bit that I just read it sounds like a good thing. I was trying to figure out how to use MVC with Windows Forms but MVVM seems a lot more apt. I think the wizard made a SQL connection string for me and I made data adapters for each table in the data set, so I think I'm good with that.

I just did some reading on typed datasets and I think I've been using typed datasets the entire time. I just went through the MS documentation on datasets when I made mine so I guess they have you make typed datasets to start.

I've graduated and I'm trying to get a job, but they all expect me to have commercial experience. I search for Graduate Developer and Junior developer, is there another word for an entry level role?

Oh man, this is what I'm afraid of. I'm graduating at the end of the year and none of my interviews panned out. I hope I can get something.
 

Chris R

Member
If you are going to use LINQ why not check out LINQ to SQL (or Entity Framework)?

It may not be the fastest method out there, but the time saving and piece of mind make it worthwhile for me. Properly design the database tables, pull into the project and enjoy my objects right away.
 

CrankyJay

Banned
If you are going to use LINQ why not check out LINQ to SQL (or Entity Framework)?

It may not be the fastest method out there, but the time saving and piece of mind make it worthwhile for me. Properly design the database tables, pull into the project and enjoy my objects right away.

You can sort of do that with datasets as well. Open up the server menu and just drag your tables into an empty dataset. Visual Studio is pretty incredible in that aspect.
 

hipbabboom

Huh? What did I say? Did I screw up again? :(
You can sort of do that with datasets as well. Open up the server menu and just drag your tables into an empty dataset. Visual Studio is pretty incredible in that aspect.

Linq expressions are pretty nice though ;) ultimately you have to decide if you want to deal with the overhead of ORM. I would only use Datasets if I didn't want to get bogged down with managing ORM code generation.
 

CrankyJay

Banned
Linq expressions are pretty nice though ;) ultimately you have to decide if you want to deal with the overhead of ORM. I would only use Datasets if I didn't want to get bogged down with managing ORM code generation.

Yeah, sadly I'm sort of pegged to data sets for the pre-existing framework I have to work off of. Just seen it from both sides. They're extra work but not unworkable.
 

poweld

Member
Fell into a dark place this evening and decided to finally learn Brainfuck.

It went as well as it could have.

Code:
++++++++[>+>>>>>++++++>>>+++++++++>++++++++++>+++++++++++>++++++++++++>+++++++++++++>++++++++++++++>+++++++++++++++>++++++++++++++++<<<<<<<<<<<<<<<<-]>>>>>>>>>----.++++>>>>>-.+++++.----<<+.-<<<<<<<<<<<++.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
Fell into a dark place this evening and decided to finally learn Brainfuck.

It went as well as it could have.

Hmmm, that looks like absolute garbage. What does it do?

Can somebody please tell me what kind of algorithm those lines use?

Problem is I don't even know what I should google, all I get is standard line algorithms like bresenham.

Are you asking for the algorithm that Epic uses? Or just curiosity?

If you're looking to implement something like that in code, paper.js has some functionality to draw lines like that.
 

Bollocks

Member
Hmmm, that looks like absolute garbage. What does it do?



Are you asking for the algorithm that Epic uses? Or just curiosity?

If you're looking to implement something like that in code, paper.js has some functionality to draw lines like that.

thank you, just curiosity.
also js is the environment I'm working with so that link is gold
 
Oh man, this is what I'm afraid of. I'm graduating at the end of the year and none of my interviews panned out. I hope I can get something.

Sorry bout my post. It isn't completely correct to say that they require "commercial" experience (though thy all make it clear that is a real plus) but rather experience in their field of programming. If you've got a good schoolwork portfolio then I'm sure that will be OK. For me my I decided to make an Oculus Rift Game for my final year project, which in hindsight wasn't the greatest idea.

What I mean is that I've noticed a lot of emphasis on what programming languages and features you have used before. I don't think I am unique in saying that moving to a new language or technology isn't a problem at all? First time I started IOS programming I picked up Objective-C without ever previously knowing anything about it.

For example I want to apply for this one junior role but it says "Whilst training can be provided to improve technical knowledge, it is vital that you have a good understanding and have experience of using WCF.". I'm still probably going to apply for it but I'm immediately on the back foot.
 

Slavik81

Member
C++ w/ clang pro-tip, since I just ran into this:

Not remembering to give your function a return value (say if it's a bool that you only check in unit tests) will generate SIGILL when you call it! At least on x64.

or: if it's going to produce such nasty code it should probably be a build error, not a warning...
You can make it an error with -Werror=return-type. This is the sort of reason why I include -Wall -Wextra -Werror in my default compiler flags.

It's probably never going to be an error by default. There's a lot of code that may require it. gcc and clang have their hands tied on this one. It's fundamentally a language issue.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43943
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
thank you, just curiosity.
also js is the environment I'm working with so that link is gold

For sure. I'm starting to use paper right now, and it just makes so many things so damn easy. It is really nice that it encapsulates itself as well so there aren't any issues with it interfering with other Javascript.

Right now I'm having difficulty figure out how to get multi-touch path drawing working, so if you happen to solve that issue be sure to let me know!

Prints out "Dota\n"

It's actually an exceedingly simple language that would require an insane amount of code to do anything meaningful in.

That's what it seems like. I'd probably go insane just attempting to write anything useful with it.
 

bigcheese

Member
So how much does the "name" of your CS degree matter and how important is theoretical computer science?

I think I might have to switch form "Computer Science (Honours)" to "Computer Science (Honours Applied Computing)" because I can't take a first year discrete math course (due to a conflict with Comp. Arch II which is a pre-req for a bunch of third year CS courses) that is a pre-req for a series of theoretical CS classes that are required for the "Honours" degree but not the "Honours Applied Computing". The main difference between these two degrees being the "Applied" one doesn't require these theoretical CS courses. Switching to the "Honours Applied" degree will save me from a messed up schedule and allow me to graduate on time, but I'm worried that having something like "Honours Applied Computing" might look bad on a resume. Of course, I'm already going to a "no-name" school so it might be a moot point anyway.

I realize my concerns over the name seem silly (I think a lot of it might come from going to high-school in Ontario, where kids are divided into "Applied" and "Academic" tracks). So I guess the more important question is, how important are the theoretical CS courses and how much would I be missing out on by not taking them?

EDIT: I suppose I could try to get permission to take two overlapping courses, which I have heard people have done before. Also, on further inspection there are a bunch of other interesting courses I would be missing out on by switching.
Discrete math is very useful, and I find it strange that your program wouldn't require it for all CS majors. It completely changed how I think about problem solving and definitely made me a better programmer.

EDIT: unless I misunderstood, and you're just worried about the courses that Discrete is a pre-req for
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
Discrete math is very useful, and I find it strange that your program wouldn't require it for all CS majors. It completely changed how I think about problem solving and definitely made me a better programmer.

EDIT: unless I misunderstood, and you're just worried about the courses that Discrete is a pre-req for

Discrete is very useful if you are taught by the correct professor.

If not, then it just becomes another math class that goes in one ear and comes out the other.
 

Mr.Mike

Member
Discrete math is very useful, and I find it strange that your program wouldn't require it for all CS majors. It completely changed how I think about problem solving and definitely made me a better programmer.

EDIT: unless I misunderstood, and you're just worried about the courses that Discrete is a pre-req for

Well, they have a first semester course called "Key Concepts in Computer Science" that covers a bunch of discrete math stuff. And then in second semester the Honours CS majors have to do "Mathematical Foundations", along with Math majors. The first year of CS and Math at my school are identical except that CS majors also have to do the Key Concepts course.

This Math Foundations course is a pre-req for the theoretical CS courses (of which there is one every year), so I'm already a year behind on that sequence of courses. Now Math Foundations overlaps with Comp. Arch II, which is pre-req for a bunch of the other third year CS courses, and would also set me back and mess up my schedule. Perhaps I should make some sort of chart to help me figure this out. I've sent out a bunch of emails asking if I can somehow be allowed to take these overlapping courses, so hopefully that pans out. Failing that I've also sent an email to the Math department asking if they plan on offering Math Foundations in the summer, so I could also go that route.
 

hateradio

The Most Dangerous Yes Man
I created a git repository and basically used the following to push it out.

I added this to the config first so that it knew where to send the branch.

Code:
[remote "test"]
    url = https://example.com/git/REPO

Then typed the following into the terminal.

Code:
git push --set-upstream test master

Config became like this.
Code:
[remote "test"]
    url = https://example.com/git/REPO
    fetch = +refs/heads/*:refs/remotes/test/*
[branch "master"]
    remote = test
    merge = refs/heads/master

Now that I know it works, I want to get rid of it, but I can't.
Code:
git push test :master

# Error
! [remote rejected] master (deletion of current branch prohibited)

I want to get rid of all the test stuff, but I'm stuck.
 

hateradio

The Most Dangerous Yes Man
I'm not sure if it worked, because I had to "--force" it because the branch was master.

I'll work on it tomorrow and see who it goes.
 

Nesotenso

Member
I am having a stupid issue with virtual box and installing xubuntu. I installed xubuntu and then openvswitch and mininet. When I power off the machine and turn it on again, virtual box asks me to install xubuntu again.

Anyone call help me? why the hell is it asking me to install xubuntu again and again?
 
You can make it an error with -Werror=return-type. This is the sort of reason why I include -Wall -Wextra -Werror in my default compiler flags.

It's probably never going to be an error by default. There's a lot of code that may require it. gcc and clang have their hands tied on this one. It's fundamentally a language issue.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43943
I'm ok with it not being an error the way gcc compiles it, but not the way clang does. Still, that's an informative link! Thanks.
 

sdijoseph

Member
Can anyone tell me if this UML diagram accurately represents this code? OvalButton overrides all 3 methods in JButton, and it also overrides the getArea() method in InfoIF. My professor also said to include multiplicity in the diagram, but I am not exactly sure how to do that.

Code:
public class OvalButton extends JButton implements InfoIF {
 
  public OvalButton(){
    this.setContentAreaFilled(false);//don&rsquo;t fill entire button
  }
 
  public boolean contains(int x, int y){
    Ellipse2D e2d = new Ellipse2D.Double(0,0,this.getWidth(),this.getHeight());
    if(e2d.contains(x,y)){ //if click outside ellipse dont arm
      return true;
    }else{
      return false;
    }
  }
  public void paintComponent(Graphics g){
    if(this.getModel().isArmed()){ //if armed change color red
      g.setColor(Color.red);
    }else{
      g.setColor(this.getBackground());
    }
    g.fillOval(0,0,this.getWidth()-1,this.getHeight()-1); 
    super.paintComponent(g); //repaint on screen
  }
  public void paintBorder(Graphics g){
    g.setColor(Color.blue);
    g.drawOval(0, 0, this.getWidth()-1, this.getHeight()-1); 
  }
 
  public double getArea() {
    // utilize getWidth() and getHeight() to compute size.
    return 0;
  }
}
 

Antiwhippy

the holder of the trombone
So guys, I'm currently moving on from a course specifically for HTML, CSS, JavaScript, SQL and php. Kinda want to start learning new languages on my own to further my skill set, and also start developing for mobile. Should I go for ruby on rails, java, c++ or any others? I know that what I've learned hasn't even really delved into the more complex parts of coding yet.
 

tokkun

Member
So guys, I'm currently moving on from a course specifically for HTML, CSS, JavaScript, SQL and php. Kinda want to start learning new languages on my own to further my skill set, and also start developing for mobile. Should I go for ruby on rails, java, c++ or any others? I know that what I've learned hasn't even really delved into the more complex parts of coding yet.

If by "mobile" you mean apps for cell phones / tablets, then Java. If you are specifically concerned with iOS devices, you could learn Objective-C instead, but it is not very broadly used outside of Apple platforms.
 

poweld

Member
So guys, I'm currently moving on from a course specifically for HTML, CSS, JavaScript, SQL and php. Kinda want to start learning new languages on my own to further my skill set, and also start developing for mobile. Should I go for ruby on rails, java, c++ or any others? I know that what I've learned hasn't even really delved into the more complex parts of coding yet.

It depends on what you're hoping to learn or make.

Based on nothing at all, I usually recommend Python as an entry/in-between step for new developers. It is easy to pick up the basics, forces you to format your code sanely, and has a great deal of capabilities/libraries to work with.

But if you're looking, say, to learn a bit more about "how a computer works", I'd suggest C.

edit: Missed the part where you said you want to work on mobile. I agree with tokkun, in that case - Java/Obj-C are the primary languages for that.
 

Antiwhippy

the holder of the trombone
Alright. Cool. I am interested in python so I might look into that too. C just feels a bit.. hardcore for me right now. Might be a project I look into someday though.

From what I've gather of ruby on rails is it just a html/css/javascript builder with pre-made objects and constraints?
 
Alright. Cool. I am interested in python so I might look into that too. C just feels a bit.. hardcore for me right now. Might be a project I look into someday though.

From what I've gather of ruby on rails is it just a html/css/javascript builder with pre-made objects and constraints?

Not quite. Rails does what PHP does, it interfaces with a database, does server-side data processing and serves HTML templates. I've never used PHP, but from what I gather Rails is more structured (it's based on the MVC pattern).
 

survivor

Banned
Not quite. Rails does what PHP does, it interfaces with a database, does server-side data processing and serves HTML templates. I've never used PHP, but from what I gather Rails is more structured (it's based on the MVC pattern).

To expand on this, Ruby on Rails is just a framework so since you want to learn a new language first you need to learn Ruby and then understand the Rails framework and how it does stuff. I'm not sure what you know about PHP so far, Antiwhippy, but I imagine you just learned the language itself and not any framework. It is possible to get something similar to Ruby on Rails using PHP if you use one of the many PHP frameworks like Yii or Laravel.
 
If by "mobile" you mean apps for cell phones / tablets, then Java. If you are specifically concerned with iOS devices, you could learn Objective-C instead, but it is not very broadly used outside of Apple platforms.

Actually given his skill set he should either learn Swift or look into a cross platform C# solution like Xamarin.
 

Antiwhippy

the holder of the trombone
Not quite. Rails does what PHP does, it interfaces with a database, does server-side data processing and serves HTML templates. I've never used PHP, but from what I gather Rails is more structured (it's based on the MVC pattern).

To expand on this, Ruby on Rails is just a framework so since you want to learn a new language first you need to learn Ruby and then understand the Rails framework and how it does stuff. I'm not sure what you know about PHP so far, Antiwhippy, but I imagine you just learned the language itself and not any framework. It is possible to get something similar to Ruby on Rails using PHP if you use one of the many PHP frameworks like Yii or Laravel.

Ah alright, yeah I haven't really explored any php frameworks yet. Just the language, learning how to interface with the database, creating actions, loops, boolean etc. and also using pdo. If I understand how php works would ruby on rails be fairly easy to transition into?
 

hateradio

The Most Dangerous Yes Man
Ah alright, yeah I haven't really explored any php frameworks yet. Just the language, learning how to interface with the database, creating actions, loops, boolean etc. and also using pdo. If I understand how php works would ruby on rails be fairly easy to transition into?
Maybe. PHP is a decent language at times, but it's lacking.

Ruby is a very particular language that is very OO at the core and works a lot with lamdas (what it mostly refers to as blocks or procs).

https://www.railstutorial.org/book

That will guide you through using Rails. Once you start, I don't think you'll look at working on a fairly large website without using a framework of some sort.

The most similar framework to Rails in PHP is Laravel. It's pretty much a clone, but just in PHP. :p
 
Top Bottom