Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Vincent K. McMahon
Sep 13, 2014

by Ralp

Janitor Prime posted:

It's not just about the number of commits, but the stability of the feature your working on and the impact it has on other people who will pull your changes in a half finished state. This is why branching is important, so that they don't fuckup the main line of development, but are free to push their changes whenever they want and in your case you can feel better about telling them to push often so that your tracking thing shows up to date information.

That all makes sense. I forgot about branching, that will be something else I need to consider

Adbot
ADBOT LOVES YOU

Luigi Thirty
Apr 30, 2006

Emergency confection port.

so i'm taking this python text adventure code and rewriting it in C#. i'm not sure about interfaces vs abstract classes in C# though.

A "verb" class is a class representing an action that can be accomplished. It contains a Perform method that performs the action of the verb in the context of the game. Perform may take a noun ("TAKE CHALICE", "OPEN DRAWER") or it may not in the case of actions not performed on a specific object ("INVENTORY", "SAVE"). The Perform method returns a string which is appended to game output.

A "noun" class represents anything that can be interacted with in the game. These come in many types (items, rooms, the player) and are used as parameters for Verbs.

Microsoft says:

quote:

Both interfaces and abstract classes are useful for component interaction. If a method requires an interface as an argument, then any object that implements that interface can be used in the argument.

so I would want to have an abstract base class that all my verbs inherit from and nouns implement an interface so I can plug any kind of noun (game items would inherit from Item which inherits from Noun, all rooms would inherit Room which inherits from Noun, the player object inherits from Noun) into the verb class that I want?

my homie dhall
Dec 9, 2010

honey, oh please, it's just a machine

Luigi Thirty posted:

so i'm taking this python text adventure code and rewriting it in C#. i'm not sure about interfaces vs abstract classes in C# though.

A "verb" class is a class representing an action that can be accomplished. It contains a Perform method that performs the action of the verb in the context of the game. Perform may take a noun ("TAKE CHALICE", "OPEN DRAWER") or it may not in the case of actions not performed on a specific object ("INVENTORY", "SAVE"). The Perform method returns a string which is appended to game output.

A "noun" class represents anything that can be interacted with in the game. These come in many types (items, rooms, the player) and are used as parameters for Verbs.

Microsoft says:


so I would want to have an abstract base class that all my verbs inherit from and nouns implement an interface so I can plug any kind of noun (game items would inherit from Item which inherits from Noun, all rooms would inherit Room which inherits from Noun, the player object inherits from Noun) into the verb class that I want?

I don't know C#, but yeah this sounds about right.

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Luigi Thirty posted:

so i'm taking this python text adventure code and rewriting it in C#. i'm not sure about interfaces vs abstract classes in C# though.

A "verb" class is a class representing an action that can be accomplished. It contains a Perform method that performs the action of the verb in the context of the game. Perform may take a noun ("TAKE CHALICE", "OPEN DRAWER") or it may not in the case of actions not performed on a specific object ("INVENTORY", "SAVE"). The Perform method returns a string which is appended to game output.

A "noun" class represents anything that can be interacted with in the game. These come in many types (items, rooms, the player) and are used as parameters for Verbs.

Microsoft says:


so I would want to have an abstract base class that all my verbs inherit from and nouns implement an interface so I can plug any kind of noun (game items would inherit from Item which inherits from Noun, all rooms would inherit Room which inherits from Noun, the player object inherits from Noun) into the verb class that I want?

if you don't have an inheritance hierarchy 100% clear in your head that'll enable massive deduplication, don't use inheritance

one of the big lessons from the early years of OO is that interfaces are far preferable to base classes in most cases

AWWNAW
Dec 30, 2008

plus you can always start with an interface and make a base class that implements or partially implements it later

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy

AWWNAW posted:

plus you can always start with an interface and make a base class that implements or partially implements it later

yup. in cases where i'm not sure which would be preferable, i'll usually start with an interface, but if i start writing lots of duplicated code in implementations that's a sign i should have an abstract base class. your point about interfaces is solid too - maybe someday you'll need to separate action verbs from interrogation verbs, for example

fortunately, visual studio has refactoring tools to extract interfaces (and i think base classes?) from classes, so you don't need to worry about getting that hierarchy perfectly right the first time

TheresNoThyme
Nov 23, 2012

chmods please posted:

but if i start writing lots of duplicated code in implementations that's a sign i should have an abstract base class.

This is the key takeaway in my opinion. Abstract classes (and class inheritance in general) should only be used when it's actually getting you something. You will know when this happens because you'll find yourself copy/pasting the same utility code into multiple sub-classes. Architectural concerns about abstract classes should be saved for larger projects, such as frameworks where you're making decisions about how 3rd parties might want to jack into your class structure at arbitrary points.

This is different from interfaces, who should be used even when they aren't immediately getting you anything because they are a pain in the rear end to refactor in later and are generically useful since programming to interfaces is a good coding practice that supports testing, dependency injection and growing code functionality in sane ways.

edit: I actually use the "talk to me about interfaces vs abstract classes" question in java interviews every now and then and it is amazing some of the nonsensical answers you get back

TheresNoThyme fucked around with this message at 17:32 on Sep 20, 2014

Luigi Thirty
Apr 30, 2006

Emergency confection port.

for now everything is interfaces and now I have a 1983-quality parser that only understands verbs that are followed by nouns

master of the sea
Apr 16, 2003

*skweeeeeee*
i started doing ios dev this last week and i managed to drag myself through the objective-c book in xcode + the first ios app + some other stuff.
so i feel i can at least read code and write code comfortably now, however, i am stumbling with some design stuff...
i ahve a main view, in this view there is a content view embedding a table view controller, there is also a button in this view, and a navigation controller in the top where the nav bar button takes oyu to the table view controller, the button on the other hand takes you to a different input view where ur supposed to fill in information to be fed back to a common model for pretty much everything, it's a list of event objects containing dates and descriptions and some other data.

my terrible instinct tells me to just go and create a singleton for keeping track of the array i feed the table view and any other information related to the model

are there other smarter or prettier ways to do this?

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
but shouldn't classes be nouns and methods be verbs? :viggo:

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Symbolic Butt posted:

but shouldn't classes be nouns and methods be verbs? :viggo:

maybe, i'm still trying to figure out the best way to do it and this way is better than the way i did it before

if I did that, how would I know that a noun supports a certain verb method in c#? I can in python with hasattr(). ex. you can look at a room, but you can't take it or switch it on. setting up every noun with a "nope" for every possible verb would get cumbersome.

or Noun.cs could have a generic error for every possible verb and nouns that support a verb overriding the "hell no" error response method maybe? idk

i do have a parser that can find verb phrases, direct objects, prepositions, and indirect objects given a sentence and a list of verbs, nouns, and prepositions though so that's cool

Luigi Thirty fucked around with this message at 04:04 on Sep 22, 2014

Elder Postsman
Aug 30, 2000


i used hot bot to search for "teens"

hi thread. i haven't posted in here in a while but i'm a full time p-langer now. i'm not as terrible as the last time i posted though but i'm still real bad.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Elder Postsman posted:

hi thread. i haven't posted in here in a while but i'm a full time p-langer now. i'm not as terrible as the last time i posted though but i'm still real bad.

hello elder potsman,

glad you're here. pleaes help yourself to a pastry, agnes brought them from her work

Luigi Thirty
Apr 30, 2006

Emergency confection port.

verb actions as methods for noun classes seems to work a lot better, yay. i even figured out how to add default definite and indefinite articles to my nouns and have "it" refer to the noun of the previous sentence!

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
I was just blindly reciting the OOP mantra I actually had no idea if it was appropriate in your case in which, you know, you're actually dealing with nouns and verbs...

but hey I'm glad I could help you! go symbolic butt go

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy

Luigi Thirty posted:

maybe, i'm still trying to figure out the best way to do it and this way is better than the way i did it before

if I did that, how would I know that a noun supports a certain verb method in c#? I can in python with hasattr(). ex. you can look at a room, but you can't take it or switch it on. setting up every noun with a "nope" for every possible verb would get cumbersome.

idea one: interfaces for supporting verbs. e.g. ITakeable has one method Take, and when you parse the take verb, see if the referenced noun object implements it (literally "if(noun is ITakeable)")

idea two: inside your noun interface you could have a dictionary of supported verbs - the key could be the verb name, the actions an Action or Func or delegate. each class declares what it supports, and provides handlers for each. i like this best because it lets you create verbs that are specific to nouns without having to define new classes or interfaces

idea three: reflection to find methods on the fly :unsmigghh:

Quebec Bagnet fucked around with this message at 08:05 on Sep 22, 2014

raruler
Oct 5, 2003

“Here lies a toppled god —
His fall was not a small one.
We did but build his pedestal,
A narrow and a tall one.”

chmods please posted:

idea three: reflection to find methods on the fly :unsmigghh:

objc wins again!

respondsToSelector:
Returns a Boolean value that indicates whether the receiver implements or inherits a method that can respond to a specified message. (required)

- (BOOL)respondsToSelector:(SEL)aSelector

:unsmigghh:

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Symbolic Butt posted:

I was just blindly reciting the OOP mantra I actually had no idea if it was appropriate in your case in which, you know, you're actually dealing with nouns and verbs...

but hey I'm glad I could help you! go symbolic butt go

I have not heard that one but my OOP education experience consists of like two semesters of C++

it makes a whole lot more sense for the parser to call Sword.Put(Butt) than Put.Perform(Sword, Butt) since everything is nice and neatly defined in Sword

e: my current implementation is method 3 which from the :unsmigghh: may be less than ideal.

Luigi Thirty fucked around with this message at 08:15 on Sep 22, 2014

Corla Plankun
May 8, 2007

improve the lives of everyone
i'm watching a d3 tutorial youtube and the guy pronounces DOM as "doom" and it is making everything so much more fun than before

Valeyard
Mar 30, 2012


Grimey Drawer
You must traverse the DOOM!

In an ever-so-slightly related topic, the tutorial videos for Angular are pretty good!

fritz
Jul 26, 2003

turn the DOM parse tree into a playable DOOM level

FamDav
Mar 29, 2008

Luigi Thirty posted:

I have not heard that one but my OOP education experience consists of like two semesters of C++

it makes a whole lot more sense for the parser to call Sword.Put(Butt) than Put.Perform(Sword, Butt) since everything is nice and neatly defined in Sword

e: my current implementation is method 3 which from the :unsmigghh: may be less than ideal.

instead of thinking about things from the view of "is my hierarchy clean?" or "is this what OOP mantra says" try and think about what you are doing most of the time in terms of implementing your game and how you can enable your future self to do that.

one of way doing this, btw, would be component driven, where each verb is a component and your nouns are entities.

entities are probably just an id number.

components are gonna be things like Take or Inventories or CharacterStats or Image or whatever. Then when the player character says "TAKE SWORD" you'll do a few things. lets assume the player's entity ID is 0 and the sword is 1.

1) you emit a message "TAKE 0 1" that your system knows to map the Take component
2) the take component determines that 1 has an instance of Take and emits a message to Inventories to add 1 to the inventory of 0
3) the system routes that message to Inventories and performs the necessary inventorying

Now if entity 3 were a wall and you tried to take it then you'd find that 3 is not in Take and so Take would emit an error, which your system could bubble up as "Wall is not takeable so dont do that". or inventory could do the full check and say that the sword doesn't fit and bubble up an error there.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

at the moment it works like this:

a sentence is passed to the parser. it identifies the verb, direct object, preposition, and indirect object (if they exist) from a list of defined verbs, nouns, and prepositions.

if it is a valid sentence, the Perform method defined in Noun is called with the direct/indirect object as parameters along with the actor that did it (the player object).

Perform looks for a method on the specific noun object that matches the verb and number of objects. if one exists, it is called with the given parameters and executes, doing whatever, and returns a string that is sent back up the chain to the game output box. if a method does not exist, then it's nonsense and returns an "I don't understand that sentence" error

Noun, the class that all interactable objects inherit from, implements methods with error messages for unsupported actions by nouns (e.g. Wall doesn't implement Take, so Noun's Take method is called instead, saying "you can't take the wall." Wall could also implement Take but return a specific error instead of putting it in the inventory, like "The wall is too big to take".). the interactable object itself overrides the error functions.

Bloody
Mar 3, 2013

ctpszs: playing around with scipy/numpy/matplotlib in ipython. this does not seem superior to matlab in any way other than freeness. largely because python seems bad.

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

fritz posted:

turn the DOM parse tree into a playable DOOM level

http://kickassapp.com/

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Bloody posted:

ctpszs: playing around with scipy/numpy/matplotlib in ipython. this does not seem superior to matlab in any way other than freeness. largely because python seems bad.

I think someone has hooked up a lisp (SBCL or CCL) to ipython notebooks so you can use a nicer language

I haven't touched ipython myself because just lol using software in a web browser, that's what native apps are for

Bloody
Mar 3, 2013

eschaton posted:

I think someone has hooked up a lisp (SBCL or CCL) to ipython notebooks so you can use a nicer language

I haven't touched ipython myself because just lol using software in a web browser, that's what native apps are for

Yeah the Web browser interface is like peak p lang.

I just really want a matlab alternative without some tragic flaw is that so much to ask for?

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

i can't destroy the copyright notice :saddowns:

Vincent K. McMahon
Sep 13, 2014

by Ralp
Got a kind of general question with regards to django development and oauth stuff.

So if you go on twitter Dev site and register an app, you get a secret key pair. You also need to specify a redirect URL to go to after authentication kicks in (I'm talking about having a "sign in with twitter" thing on my site)

Problem is, this redirect URL has to strictly match what will actually happen otherwise it will reject the login. This makes development ntricky. I currently have the redirect set to..127.0.0.1 blah blah for my local running test server. Which works.

But it means to test on the site which is live, I need a separate key Blair with the proper URL.

So I was thinking of making some script that detected whether it was running locally or online and had django point to the right key pairs

I'm not sure how, I'm sure I'll hack it out, but just wondering if this is something that gas been faced here before

TheresNoThyme
Nov 23, 2012

Vincent K. McMahon posted:

Got a kind of general question with regards to django development and oauth stuff.

So if you go on twitter Dev site and register an app, you get a secret key pair. You also need to specify a redirect URL to go to after authentication kicks in (I'm talking about having a "sign in with twitter" thing on my site)

Problem is, this redirect URL has to strictly match what will actually happen otherwise it will reject the login. This makes development ntricky. I currently have the redirect set to..127.0.0.1 blah blah for my local running test server. Which works.

But it means to test on the site which is live, I need a separate key Blair with the proper URL.

So I was thinking of making some script that detected whether it was running locally or online and had django point to the right key pairs

I'm not sure how, I'm sure I'll hack it out, but just wondering if this is something that gas been faced here before

You've basically discovered the personal development use-case for environment vars. This is useful not just for oauth, but also for things like having a database that runs on your PC for local development and then switching to a externally hosted db when you release.

I don't know django well enough to know the standard approach in that language, but in general you don't need a custom script to detect where the code lives on start-up. You can just have a property file that you switch between "env=dev" and "env=prod" manually before releasing code (easy kind of lame solution), or preferably this happens automatically as part of your build process. Then some code in your project reads that information at start-up and loads the proper oauth config, db config, etc...

Corla Plankun
May 8, 2007

improve the lives of everyone

Bloody posted:

Yeah the Web browser interface is like peak p lang.

I just really want a matlab alternative without some tragic flaw is that so much to ask for?

whats R's tragic flaw?

i've always had matlab so i never figured it out (aside from the weird syntax) but I am curious to know

fritz
Jul 26, 2003

Bloody posted:

Yeah the Web browser interface is like peak p lang.

most of the time i just use the command line ipython

Bloody
Mar 3, 2013

Corla Plankun posted:

whats R's tragic flaw?

i've always had matlab so i never figured it out (aside from the weird syntax) but I am curious to know

i was going to say license costs then i realized R is free idk what i was thinking of (stata maybe?) so i dunno! ive never used it ill have to actually take a look at it, particularly because what im mostly interested in right now is statistical instead of dsp

does R have any good ide/environments?

fritz
Jul 26, 2003

Bloody posted:

i was going to say license costs then i realized R is free idk what i was thinking of (stata maybe?) so i dunno! ive never used it ill have to actually take a look at it, particularly because what im mostly interested in right now is statistical instead of dsp

does R have any good ide/environments?

the mac interface is ok


what kind of stats you got

Bloody
Mar 3, 2013

Big Data :smugmrgw:

in one case, ~1 tb of csv representing many sets of low-dimensional data
in the other, ~1 tb of high-dimensional binary data (~R240)

in both cases im mostly interested in fiddling with subsets in a quick visual way then likely doing heavy lifting in c/c++

Valeyard
Mar 30, 2012


Grimey Drawer
Thanks!

Valeyard fucked around with this message at 18:50 on Sep 23, 2014

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Bloody posted:

Yeah the Web browser interface is like peak p lang.

I just really want a matlab alternative without some tragic flaw is that so much to ask for?

evidently

I bought a raspberry pi because it has free mathematica, sure it's s-l-o-w mathematica but at least I can VNC in from a real computer and it's still faster than anything I used in the 90s

Valeyard
Mar 30, 2012


Grimey Drawer

Valeyard posted:

Thank you! You made me realise I was massively over complicating things first of all.

In the live site I can specificy, in the WSGI file, which settings file to use. So I can just have two different setting files - which is fine.

But, I would rather have all my main settings live in..settings.py . And then have two other files (dev.py and prod.py) that inherrit everything from settings.py but override a few things - is this easily possible?

Do I just need to do some form of import settings.py or from settings.py import * inside the dev/prod file?

The answer to this is...yes!

That works great in dev, the prod changes should work too. Thanks again!

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Corla Plankun posted:

whats R's tragic flaw?

GPLv3

Adbot
ADBOT LOVES YOU

compuserved
Mar 20, 2006

Nap Ghost
R doesn't even have a native 64-bit integer type pissssssss

  • Locked thread