• 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

Koren

Member
Just wondering man, why trying to make it just 1 line??
Hey, it's Cpp_is_king who asked ^_^

More seriously, it's like code golf
- it's fun (at least to some people, myself included)
- it helps you learning more about the language

Beside a more complete understanding of the language, it doesn't have much practical use per se (although shorter code is sometimes easier to understand)
 

Chris R

Member
Just wondering man, why trying to make it just 1 line??

Because the professor said he's seen it done in 2-3 lines, and when a professor says that they usually want something in that range or they'll deduct points for a perfectly fine working answer because the person turning in the assignment wasn't novel enough or some bullshit like that.
 

Koren

Member
Because the professor said he's seen it done in 2-3 lines, and when a professor says that they usually want something in that range or they'll deduct points for a perfectly fine working answer because the person turning in the assignment wasn't novel enough or some bullshit like that.
I don't agree with the idea of deducting point for lack of compacity... Especially if that means using tricks. There's usually an expected complexity, and a basic understanding of the language is needed (some solutions are really rough, even if that works), but beside that...

Also, 2-3 lines and 1 line is a different sport... A 3 lines solution may be better (because nicer), and in your case a table is better than 10 different variables for counters, when a lot of 1-liners are just plain awful.

I have a couple students that always aim for 1-liners, I try to make them change their habits. I don't really mind (especially since I enjoy it myself), but in some exams, some people may not like unreadable solutions at all.
 

Mine01

Member
Shits and giggles.
Fair enough
Hey, it's Cpp_is_king who asked ^_^

More seriously, it's like code golf
- it's fun (at least to some people, myself included)
- it helps you learning more about the language

Beside a more complete understanding of the language, it doesn't have much practical use per se (although shorter code is sometimes easier to understand)

Well I get that, most of the time I try to make my code the most compact possible, tbh I end with shit that just I understand.

Because the professor said he's seen it done in 2-3 lines, and when a professor says that they usually want something in that range or they'll deduct points for a perfectly fine working answer because the person turning in the assignment wasn't novel enough or some bullshit like that.
In my school, here in Mexico, is quiet the contrary, I've lost points because I used too few lines(braces in same line as an if, stuff like that) just because.

I don't agree with the idea of deducting point for lack of compacity... Especially if that means using tricks. There's usually an expected complexity, and a basic understanding of the language is needed (some solutions are really rough, even if that works), but beside that...

Also, 2-3 lines and 1 line is a different sport... A 3 lines solution may be better (because nicer), and in your case a table is better than 10 different variables for counters, when a lot of 1-liners are just plain awful.

I have a couple students that always aim for 1-liners, I try to make them change their habits. I don't really mind (especially since I enjoy it myself), but in some exams, some people may not like unreadable solutions at all.

I agree with this
 

Chris R

Member
I don't agree with the idea of deducting point for lack of compacity... Especially if that means using tricks. There's usually an expected complexity, and a basic understanding of the language is needed (some solutions are really rough, even if that works), but beside that...

Also, 2-3 lines and 1 line is a different sport... A 3 lines solution may be better (because nicer), and in your case a table is better than 10 different variables for counters, when a lot of 1-liners are just plain awful.

I have a couple students that always aim for 1-liners, I try to make them change their habits. I don't really mind (especially since I enjoy it myself), but in some exams, some people may not like unreadable solutions at all.

I'm just venting from personal experience. I had a professor who gave me sub 80% on perfectly working answers because his solution did things a different way (that he didn't teach, but then again, he read from books and slides, he never taught).
 

vypek

Member
Been learning Python but the tutorials I've been looking at are Python 2. Should I stop and just take a look at 3 instead? Not sure if 3 is widely used yet or if there is enough difference to warrant learning 3
 

BeforeU

Oft hope is born when all is forlorn.
Guys why do I still find programming very intimidating. Is there any tips you can give me to get over the fear.
 

BeforeU

Oft hope is born when all is forlorn.
what part is scary?

algorithms mostly. If you give me a problem that involves writing even simplest for loop, I will take me forever. When I watch the tutorials and solutions everything seems straight forward.
 

Makai

Member
algorithms mostly. If you give me a problem that involves writing even simplest for loop, I will take me forever. When I watch the tutorials and solutions everything seems straight forward.
Just write a lot of code, preferably on something fun like a game.
 

Kansoku

Member

oemt4qm7no6y.jpg
 

Koren

Member
I'm just venting from personal experience. I had a professor who gave me sub 80% on perfectly working answers because his solution did things a different way (that he didn't teach, but then again, he read from books and slides, he never taught).
Said like that, I disagree.

I may remove some points for bad complexity (O(n²) solution when there's an obvious O(n) one) or for a really, really clumsy code (with respect to their level), but not for doing things in a different way. And I'm impressed by the number of solutions they come up with (including from time to time with thing I wish I had thought)

As far as "what's allowed in syntax, what isn't", it's a difficult problem. In Python, I usually say "all that's standard and doesn't require modules except math, unless there's other explicit rules", because I think that's the rules in the entrance exams for the schools they're targeting, but that depends on why they're studying CS.

Guys why do I still find programming very intimidating. Is there any tips you can give me to get over the fear.

There is no fear, there is the Code


Jump in... Just try*. If it works, great. If it doesn't, try to understand what went bad, and when you succeed, try again.

Don't feel bad if your solution is clumsy. Make it work first. Everything is obvious a posteriori. But you won't find the best solution for your first attempt.

Also, look at a lot of example. Try to understand, not to memorize. You'll remember a small part of it if you understand it well, and soon, you'll reuse some of those ideas.

I'd suggest actually typing those examples, too. There's one thing to salvage from "Learn Python the Hard Way" (no book can be 100% bad ;) ): there's mechanical memory involved, and since it's slower, you'll remember it better.


* Yes, I know... WIth the line above, it's inconsistent ^_^
 
The randint-less (and thus import-free) version, using Park and Miller version of Lehmer PRNG, a dirty trick with id() to get a pseudo-seed (since I can't use time or anything like this), and a dirtier trick to create a generator which isn't stateless:

Code:
print("Range     Result  Graph\n--------- ------- --------\n" + "\n".join("{:2} - {:3}  | {:2} |  {}".format(10*k+1, 10*(k+1), s, '*'*s) for k, s in ( (k, sum(1 for e in l if 10*k<e<=10*k+10)) for k, l in enumerate([[ (L.append(L.pop() * 16807 % 2147483647), L.append(L[-1]), L.pop()%99+1)[2] for L in ([[id("This is a trick to get a seed")]]*200) ]]*10) )) )

A bit shorter:
Code:
print("\n".join(["Range     Result  Graph","-"*9+" "+"-"*7+" "+"-"*8]+["{:2} -{:4}  |{:3} |  {}".format(k,k+9,s,'*'*s)for k,s in((k,sum(k<=e<k+10 for e in l))for k,l in zip(range(1,92,10),[[(L.extend([L.pop()*16807%2147483647]*2),L.pop()%99+1)[1]for L in([[id(dict())]]*200)]]*10))]))

mhmm, mhmm I understand some of those methods.
 

Mine01

Member
So guys I have a questions about unit testing.

I've been using .net mvc lately, and one of my co workers was talking about unit testing the other day, and tbh it sounds pretty great, but I do not understand how I would use it in "real world" scenarios.

Can anyone help me here or point me on the right direction??
 

Somnid

Member
Guys why do I still find programming very intimidating. Is there any tips you can give me to get over the fear.

Many things aren't complicated but subtle, but that's expected. Most of programming is figuring out how the hell you're gonna do something and then figuring out why it didn't work, that's true no matter how experienced you are. Sometimes an 8 hour day might produce 2 lines of code. My tips would be:

- Don't feel discourage if you don't understand algorithm problems or have trouble solving them. Realistically, most of the time these are already solved for you, much of the time brute force is good enough, and you pretty much only get good at that stuff by doing it, a lot and not all programmers do.

- Don't feel bad if you don't feel you grasp something the first time. Most of my knowledge and comfort came from revisiting the same thing often months or years apart. Nobody reads an intro to C++ book and says "yup, I got that." Most probably finish and think "I know some of those words" and it's not until later attempts it starts clicking.

- A lot of initial understanding comes from building a project. Often learning material lays things out in a happy-path way, but to actually remember and understand takes forcing yourself to look things up and struggle through them. Note that just looking things up is itself a skill you need. Usually your first (many) attempts at solving a problem suck but as you get more comfortable you'll find little tricks to make it better.
 

Somnid

Member
So guys I have a questions about unit testing.

I've been using .net mvc lately, and one of my co workers was talking about unit testing the other day, and tbh it sounds pretty great, but I do not understand how I would use it in "real world" scenarios.

Can anyone help me here or point me on the right direction??

First understand what you want to gain from testing. Usually this is "more reliable code" but it can also be "documentation" or "debuggability" or "better code structure" (this is because writing testable code tends to make you write better code). Then make tests with that in mind.

For .net mvc your best bet is Nunit for testings and Moq for mocks. Basically the idea is to test a piece of logic (typically inputs and outputs to a function but not always). So you setup a few cases where the inputs should produce an expected output and assert that the output was correct:

Class:
Code:
    public static class StringExtensions
    {
        public static int? AsIntOrDefault(this string str)
        {
            int result;
            if(!int.TryParse(str, out result)){
                return null;
            }
            return result;
        }
    }

Test with nunit:
Code:
    [TestFixture]
    public class StringExtensionsTests
    {
        [Test]
        public void ParseIntOrDefault_should_parse_int()
        {
            Assert.That("123".AsIntOrDefault(), Is.EqualTo(123));
        }
        [Test]
        public void ParseIntOrDefault_should_default_if_not_int()
        {
            Assert.That("abc".AsIntOrDefault(), Is.Null);
        }
    }

Tests are usually in separate project, so if the StringExtensions class was in Utilities project, I'd write the tests in UtilitiesTests or something. Typically with MVC you will use dependency injection where you write an interface for each object and have the dependency injection container fill it in for you with things you register. In your test project instead of injecting the real thing you inject with mocks that you setup to give dummy data to make testing more deterministic.

The idea is once you have these tests setup, you have an automated build system run them on check-ins so that if someone pushes code that breaks unit tests you can fix it. TeamCity is a good option for .NET.
 

Makai

Member
I've become radicalized by the ubiquity of Unity games. Every single one of them stutters on my gaming PC even though their asset load is minimal. Then I play unfaltering games like The Witness and the secret sauce is foregoing proprietary engines*.

*notable exception of No Man's Sky
 
There's literally nothing happening in the world of The Witness at any given moment. Stuff only happens as a result of interactions, with maybe 1-2 exceptions. Big difference
 

Makai

Member
There's literally nothing happening in the world of The Witness at any given moment. Stuff only happens as a result of interactions, with maybe 1-2 exceptions. Big difference
The closest game I can think of is Firewatch, which I played last night. It has some simple physics with interactable objects, but otherwise they're both open worldy games with similar aesthetics. A similar amount of "stuff happening" in the early part of the game I'm in - walk along a path until you get to the next interactable checkpoint. The Witness is free-roam but the viewable land mass is probably smaller - although they put the whole island in view during the credits for funsies. I think Firewatch has larger textures, but nothing outrageous. Overall, the asset loads are probably in the same ballpark, but the performance difference is enormous.

And I'm not picking on this game - it's all of them. Many Unity games run well most of the time, but inevitably hit intermittent GC spikes. It's more tolerable in some games than others - hard to spot in Steven's Sausage Roll with discretized movement, a steady camera, and no animation. But then on the unacceptable end of the spectrum, it's somehow become the standard engine for VR, a platform for which frame drops and microstutter result in the user lying down immediately afterwards.

This stuttering is everywhere now and the official best practices involve finding the least awful places for it and intentionally stuttering there. I even saw it in Super Mario Run, which was developed in-house at Nintendo by the same team working on Zelda. If they transition to using Unity for flagship titles I'll be sadface.
 

Tristam

Member
Been learning Python but the tutorials I've been looking at are Python 2. Should I stop and just take a look at 3 instead? Not sure if 3 is widely used yet or if there is enough difference to warrant learning 3

Newer linux distros tend to come pre-stocked with both Python 2 and 3, and I would say Python 3 has fairly wide distribution now, but 2 is still used plenty. But really it doesn't matter that much as the differences are fairly minimal.
 

Koren

Member
I have a question about Python style...


Let's suppose I want a class with a class attribute that is quite big (a lut table, for example). Or that can't be "pre-computed" in source code.

I want the class attribute to be set either at the time of the class declaration, or at the time of the creation of the first instance, or at the first access to the lut, I don't care.


I see plently of ways to do it, but I really like none of them.


Edit: just to be clear, I use [ 1, 2, 3 ] in the following example to avoid making the examples complex, consider it the result of a (classmethod or staticmethod) function call... Or course, if it was really [ 1, 2, 3 ], I could define it directly...



Solution 1: do it at the creation of the first instance
Code:
class cfoo :
    lut = None
    
    @classmethod
    def InitLut(cls) :
        cls.lut = [ 1, 2, 3 ]
    
    def __init__(self) :
        if self.lut is None :
            type(self).InitLut()

I'm not that fond of putting an initializer of a class attribute in the __init__ function, and I don't find type(self) to call a classmethod really nice.

Solution 2: use a function called at class definition
Code:
def InitLut() :
    return [ 1, 2, 3 ]
    
class cfoo :
    lut = InitLut()
    
    def __init__(self) :
        pass

I kinda like this method, but I not fond of InitLut being declared *outside* of the class. I would prefer a @staticmethod inside cfoo, but I don't see how to call it?

Solution 2b: use a class method
Code:
class cfoo :
    @classmethod
    def InitLut(cls) :
        cls.lut = [ 1, 2, 3 ]
    
    lut = None
    
    def __init__(self) :
        pass

cfoo.InitLut()

The initialization function is inside, but that require a call from outside.

Solution 2c: well, why not using a class decorator for this...
Code:
def InitLut(cls) :
    setattr(cls, "lut", [ 1, 2, 3 ])
    return cls

@InitLut
class cfoo() :
    def __init__(self) :
        pass

I doubt it's better, it even hides the class attribute (you could keep it in the definition, but well...)

Solution 2d: well, let's use a decorator that force the initialization
Code:
def CallInit(cls) :
    cls.Init()
    return cls

@CallInit
class cfoo() :
    @classmethod
    def Init(cls) :
        cls.lut = [ 1, 2, 3 ]
    
    def __init__(self) :
        pass

Not convincing either, I'd say.

Solution 3: use a property for the class attribute, so you can create a getter that initialize the lut at first use
Code:
class cfoo :
    def get_lut(self) :
        if type(self)._lut is None :
            type(self)._lut = [ 1, 2, 3 ]
        return type(self)._lut
            
    lut = property(get_lut)

    _lut = None
        
    def __init__(self) :
        pass

I don't like it either, you need a _lut attribute (or do really dirty tricks so that you don't fall in an infinite loop with the getter), and there's some overhead because you'll check initialization each time you try to access the attribute lut.

Solution 3bis: alternative using decorator:
Code:
class cfoo :
    @property
    def lut(self) :
        if type(self)._lut is None :
            type(self)._lut = [ 1, 2, 3 ]
        return type(self)._lut
    
    _lut = None
        
    def __init__(self) :
        pass

Same issues, and doesn't seem really readable to me...

Solution 4: be nasty, use @property so that you can call a function the first time you try to access to the class attribute, and use this function to redefine the class attribute to a normal attribute.
Code:
class cfoo :
    @property
    def lut(self) :
        setattr(type(self), "lut", [1, 2, 3 ])
        return type(self).lut
    
    def __init__(self) :
        pass
I somehow like it's self-contained, doesn't have overhead, but it's still a trick where the class kinda "evolve" at first access to lut, and it may not be the most obvious thing to understand.


I'll stop there, I have plently of other suggestions (using metaclasses, using inheritance, using __init__ as a class initializer and redefining it before exiting to initialize instances for next calls...) but there's not a single one that I find 100% appealing. Bundling the class in a module may be the most interesting solution, but I think it would be a waste to create (and import) a module just because you want to initialize a class attribute...

Any suggestion? I feel like I missed something obvious...


Googling it is difficult, especially when a majority of people doesn't even understand the different between a class attribute and the attribute of an instance :/
 
Koren said:
Googling it is difficult, especially when a majority of people doesn't even understand the different between a class attribute and the attribute of an instance :

Haha that's me.

Been messing with (g)awk lately. Fast solution for annoying problems.
 

leroidys

Member
Any suggestion? I feel like I missed something obvious...


Googling it is difficult, especially when a majority of people doesn't even understand the different between a class attribute and the attribute of an instance :/

I'm not quite sure what the value of this is. Why do you need a data structure as a class attribute? In my experience, people tend to lean too hard on the flexibility of pythons OO paradigms to their detriment. Can you just hack together a singleton that your class instances call?
 

Koren

Member
I'm not quite sure what the value of this is. Why do you need a data structure as a class attribute? In my experience, people tend to lean too hard on the flexibility of pythons OO paradigms to their detriment. Can you just hack together a singleton that your class instances call?
I could, but as solutions I suggested, I don't like it much.

I'll take an example. I have an B&W image class, that hold digital values of intensity.

I want to be able to have a method that gives the real intensity of a given pixel (as a floating point value). For this, you have to use the gamma curve.

But since you don't want to compute the conversion, the easiest solution would be to have a table of floats where table[0] = 0.0, ... table[127] = 0.2, ... table[255] = 1.0.

The table is the same for all instances of the class, so it makes sense, to me, to have a class attribute that holds the table, so that it is shared by all the instances.

The problem is that I don't see a nice way to initialize the table (at any time, as long as it is done before it's used) only with code from inside the class, unless I write all the values directly in the class definition (which is unusable for large tables, or if the table isn't totally fixed).

Well, except in this case, where a list comprehension will work, but I'm thinking broader. There's plently of situations where it's useful, like a Reed-Solomon class that use an antilog table, a color classifier that uses a LUT table, etc.


A singleton here is even more overkill than solutions I laid above (or I haven't spoken of... for example, using __new__).


I was simply looking for something like a __classInit__ function called at class declaration. There *is* code executed at the class declaration. But the problem is that it can only use code from outside the class, and you can only do list comprehensions, lambdas, etc.

That's not a need (again, there's 200 ways of doing this), I just want to be sure I haven't missed a special method or trick for declaring/initializing classes.
 

leroidys

Member
I could, but as solutions I suggested, I don't like it much.

I'll take an example. I have an B&W image class, that hold digital values of intensity.

I want to be able to have a method that gives the real intensity of a given pixel (as a floating point value). For this, you have to use the gamma curve.

But since you don't want to compute the conversion, the easiest solution would be to have a table of floats where table[0] = 0.0, ... table[127] = 0.2, ... table[255] = 1.0.

The table is the same for all instances of the class, so it makes sense, to me, to have a class attribute that holds the table, so that it is shared by all the instances.

The problem is that I don't see a nice way to initialize the table (at any time, as long as it is done before it's used) only with code from inside the class, unless I write all the values directly in the class definition (which is unusable for large tables, or if the table isn't totally fixed).

Well, except in this case, where a list comprehension will work, but I'm thinking broader. There's plently of situations where it's useful, like a Reed-Solomon class that use an antilog table, a color classifier that uses a LUT table, etc.


A singleton here is even more overkill than solutions I laid above (or I haven't spoken of... for example, using __new__).


I was simply looking for something like a __classInit__ function called at class declaration. There *is* code executed at the class declaration. But the problem is that it can only use code from outside the class, and you can only do list comprehensions, lambdas, etc.

That's not a need (again, there's 200 ways of doing this), I just want to be sure I haven't missed a special method or trick for declaring/initializing classes.
I think a metaclass would solve this for you. Personally I wouldn't use a class at all.
 

Koren

Member
I think a metaclass would solve this for you.
You'll notice it was among possibilities in my original post ;)

It solves the problem (as other solutions), but I still think it's unsatisfying... there should be a way to initialize class attributes.

Personally I wouldn't use a class at all.
The example above was a way to describe the behaviour I was after... not a complete example, and not what I'm after (but should I explain what I want to do, I'd fill the thread even quicker). Only the mechanisms are the same.
 

leroidys

Member
You'll notice it was among possibilities in my original post ;)

It solves the problem (as other solutions), but I still think it's unsatisfying... there should be a way to initialize class attributes.


The example above was a way to describe the behaviour I was after... not a complete example, and not what I'm after (but should I explain what I want to do, I'd fill the thread even quicker). Only the mechanisms are the same.
I mean that having a unique, persistent data structure bound to the class definition seems inherently obtuse and unwieldy.
 

vypek

Member
Newer linux distros tend to come pre-stocked with both Python 2 and 3, and I would say Python 3 has fairly wide distribution now, but 2 is still used plenty. But really it doesn't matter that much as the differences are fairly minimal.

Thanks. Appreciate the input :)
 

Koren

Member
I mean that having a unique, persistent data structure bound to the class definition seems inherently obtuse and unwieldy.
Well, to me a LUT is often just a way to speed-up a function/method...

Since you have class methods, I think it make sense to allow those class methods to be efficient, and if that means having a LUT tied to the class, well, the whole idea doesn't seem absurd.

Granted, you could make it an option, only build the LUT when it's needed, and/or allow the user to free the space...

But at the same time, for smaller LUTs, the memory required may be lower than methods themselves. In fact, sometimes, it could even make the class smaller.
 

leroidys

Member
Well, to me a LUT is often just a way to speed-up a function/method...

Since you have class methods, I think it make sense to allow those class methods to be efficient, and if that means having a LUT tied to the class, well, the whole idea doesn't seem absurd.

Granted, you could make it an option, only build the LUT when it's needed, and/or allow the user to free the space...

But at the same time, for smaller LUTs, the memory required may be lower than methods themselves. In fact, sometimes, it could even make the class smaller.
Fair enough, I'm definitely no design guru :)
 

shoreu

Member
So here's the assignment

IT 3883
Assignment 2: Individual Lab 2
Review Chapter 4. In particular, walk through The Account example on pages 126, 127, 129 and
130.
Create a class called Artist that contains 4 pieces of information as instance variables: name (datatype string), specialization – i.e., music, pottery, literature, paintings (datatype string), number of art items (datatype int), country of birth (datatype string).
Create a constructor that initializes the 4 instance variables. The Artist class must contain a property for each instance variable with get and set accessors. The property for number should verify that the Artist contributions is greater than zero. If a negative value is passed in, the set accessor should set the Artist’s number to 0.
Create a second class ArtistTest that creates two Artist objects using the constructor that you developed in the Artist class. Display the name, specialization, number of art items, country of birth. Your assignment submission must include
Source code (2 .cs files ) ( .5 pt – constructor is called and initializes 4 instance variables; .5 point –correct properties including validation; .5 point – 2 objects created; .5 point – 2 objects created)
Screen shot of the program running with reasonable test data( 2 pts)
Compiled (.exe) file that runs the app ( 1 point ) This file is an application file. IT DOES NOT have xml, vshost, or config associated with it.
Homework assignments will NOT be accepted by email. Submit by midnight Sunday via D2L.

and here is the code that I submitted that does everything she ask for.


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Assignment_2_App_dev
{

/*
 * Assignment 2 
 * Feburary 2, 2017
 */
    public class Artist
    {
        public string ArtType { get; set; }
        public int age { get; set; }
        public int projects { get; set;}
        public string birthplace { get; set; }
        public string name { get; set; }

        //Artist
        public Artist(string Name,string Birthplace, string spec, int contributions)
        {
            name = Name;
            birthplace = Birthplace;
            ArtType = spec;
            projects = contributions; 
               
          // If statement to ensure that projects cannot be less that zero
            if(projects < 0)
            {
                projects = 0;
            }        
        }


        public override string ToString()
        {
            return name + "\n"+ birthplace +"\n" + ArtType + "" + projects;
        }


       
    }
}



Code:
using Assignment_2_App_dev;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class ArtistTest
{
    static void Main(string[] args)
    {

        Artist artist = new Artist("Name: Machoman Randy Savage", "Birthplace: New York, New York", "Specilization: Actor\nNumber of Projects: ", -500);
        Artist artist2 = new Artist("Name: Leonardo Dicaprio", "Birthplace: Los Angeles, California", "Specilization: Actor\nNumber of Projects: ", 30);
        Artist artist3 = new Artist("Name: Michelangelo", "Birthplace: Tuscany, Italy", "Specilization: Sculptor\nNumber of Projects: ", 100);
        Artist artist4 = new Artist("Name: Beyoncé Giselle Knowles", "Birthplace: Houston, Texas", "Specilization: Singer\nNumber of Projects: ", 176);


        System.Console.WriteLine(artist.ToString());
        Console.WriteLine("\n\n");
        System.Console.WriteLine(artist2.ToString());
        Console.WriteLine("\n\n");
        System.Console.WriteLine(artist3.ToString());
        Console.WriteLine("\n\n");
        System.Console.WriteLine(artist4.ToString());



        /* if(artist.projects < 0 )
         {
             artist.projects = 0;
         }
         */

        //Console.WriteLine("Let me introduce {0}", artist);
        Console.ReadLine();
    }

}

The language is C# The outputs come out correctly exactly how she wants them in the rubric.

She Claims that

" if(projects < 0)
{
projects = 0;
} " should be in set property

and gave me a 70 on the assignment. Not only did she do this but it was after initially giving me a 90 on the assignment.
 

Haly

One day I realized that sadness is just another word for not enough coffee.
If a negative value is passed in, the set accessor should set the Artist's number to 0.
As it is, someone can use the set accessor to change projects to negative, that's where she's deducting the points.
.5 point &#8211;correct properties including validation

30 is a bit harsh though.
 

MiszMasz

Member
She ... gave me a 70 on the assignment. Not only did she do this but it was after initially giving me a 90 on the assignment.
Correct me if i'm wrong as my background's Java not C#, but it looks to me as if modifying the default setter and calling it in the constructor to perform the check before assignment, rather than just having the if statement in the constructor itself potentially changing the value after it's already been set once is what's she's asking for:
The Artist class must contain a property for each instance variable with get and set accessors. The property for number should verify that the Artist contributions is greater than zero. If a negative value is passed in, the set accessor should set the Artist’s number to 0.

Similar to the first example, i'd have thought.

I agree that it's a large knock she's given to your score though.
 

Somnid

Member
Just got a rejection from a big software company, apparently I'm strong at coding and problem solving but they feel the things I've worked on weren't technically challenging enough and therefore I lack a broader knowledge (I interpreted this to meaning they wanted more experience with cloud infrastructure/hyper-scale applications). That's like part of the reason I want a new job, to do more technically challenging things. Kinda frustrating all that effort to what I thought was a good interview boils down to "work 5 years at Microsoft and call us."
 

Koren

Member
It's indeed annoying, I hope you'll be luckier soon...

As it is, someone can use the set accessor to change projects to negative, that's where she's deducting the points.

30 is a bit harsh though.
I agree.

It seems to be a "all or nothing case", though. If I understood weel, there's 3 points for the assignment. If you convert these to /100 notation, rounding up:
3 > 100
2.5 > 90
2 > 70
1.5 > 50
1 > 40
0.5 > 20

So it could make sense, since the setter isn't correct... I would use a finer points distribution, though, because the result is quite harsh.

I have an advice, though: when you've finished an assignment, try to "correct" it by reading all the specifications again, one by one, trying to criticize you code yourself. It works very well to avoid this kind of thing.

Fair enough, I'm definitely no design guru :)
Not that I am, far from it. I may be wrong, and I keep wondering how I should write things. I should find good books on design patterns.

But the discussion was interesting, thanks.
 

MrOogieBoogie

BioShock Infinite is like playing some homeless guy's vivid imagination
I managed to get to Week 7 in CS50x but had to put the course on hold as the time commitment became YUGE. I had zero computer science knowledge before starting the course, and though I learned a shit-ton, the material became a bit overwhelming and the assignments were taking me a week or two to complete (while committing many hours to them).

If I want to jump back in with some of the knowledge I've acquired but learn in a less daunting environment, what kind of courses should I look at? Or am I SOL if I couldn't even finish CS50? I feel like a goddamn failure.
 

Somnid

Member
I managed to get to Week 7 in CS50x but had to put the course on hold as the time commitment became YUGE. I had zero computer science knowledge before starting the course, and though I learned a shit-ton, the material became a bit overwhelming and the assignments were taking me a week or two to complete (while committing many hours to them).

If I want to jump back in with some of the knowledge I've acquired but learn in a less daunting environment, what kind of courses should I look at? Or am I SOL if I couldn't even finish CS50? I feel like a goddamn failure.

Why not take the same course? It should be easier the second time. Most hard subjects I find take many tries before they fully stick and you get comfortable with them. You can also just do things on your own. There's no shortage of lessons and tutorials online.
 

cyborg009

Banned
Can anyone help me with this Powershell script? I wanted to this part of the code to enable/disable a trigger in a windows task scheduler.

Code:
    $TaskScheduler = New-Object -COMObject Schedule.Service
    $TaskScheduler.Connect()
    $TaskFolder = $TaskScheduler.GetFolder("\") # If your task is in the root "folder"
    $Task = $TaskFolder.GetTask("test")
    $Triggers = $Task.Definition.Triggers

I'm not sure how to use

RegisterTaskDefinition()
 

Slo

Member
I attended a lecture today by Steve Wozniak at a local college.

Nobody loves Steve Wozniak more than Steve Wozniak.
 

midramble

Pizza, Bourbon, and Thanos
Any pages in this thread with a bunch of IDE talk? I'm in the market for a new one.

Bulk of the work is in Java and I've been using eclipse for a good while. Also use it for a bit of markup language stuff with some sprinkled JS. Though it'll probably be heavier JS soon. What I love about Eclipse are features like code completion/generation, javadocs when hovering over methods, functions, and classes, syntax corrections, and all the other alerts/warnings that assist me in writing correct code before I compile and get a depressing dump.

My problem came from how much mobile coding I've been having to do because of my dayjob. As in my day job keeps me mobile so my hobby of programming has to be done on the road more often. I had to move my code from only being local projects to being in a private github repo. I run my code through a maven/jenkins build server and deploy directly from there for testing now. I've used the github plugin for eclipse so I can make direct changes to my code from anywhere and deploy from anywhere. That worked fine for a while, but now I find myself without personal laptop often and changing computers often. I love using eclipse but I hate setting it up, downloading all the plugins again, and configuring from scratch.

Does anyone know any other IDEs with the capabilities of eclipse that are easier on setup (as in can get on any computer, download, link to github, and just start hacking), or even a web IDE with similar capabilities?
 

Slo

Member
IntelliJ is much much much better than Eclipse, especially for code completion and AndroidSDK development. I love it, but unfortunately it's not free.

As far as JS development goes, most of the full time web developers that I work with just use SublimeText with a bunch of add ons.
 
Having some trouble conceptualizing the run time.

Let's say I run Dijkstra's algorithm on every single vertex in graph. Or V times.

A single run of the algorithm is O(E + V lg V). What is the run time of an algorithm that calls an "O(E + V lg V)" V number of times? times?
 

leroidys

Member
Having some trouble conceptualizing the run time.

Let's say I run Dijkstra's algorithm on every single vertex in graph. Or V times.

A single run of the algorithm is O(E + V lg V). What is the run time of an algorithm that calls an "O(E + V lg V)" V number of times? times?

What would be your first guess?
 
Top Bottom