Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 720 721 [722] 723 724 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 890207 times)

strainer

  • Bay Watcher
  • Goatherd
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10815 on: April 12, 2018, 02:36:29 pm »

I appreciated MorleyDevs explanations of formal usage of terms which also have more casual usage. DIP seems to be a principal or discipline to follow in order to make code compatible with certain modern working patterns - rather than an ability or optional feature of a language.

Casually "unit testing" may just refer to testing bits of code, but in more formal realms I notice it refers to tests written to a template allowing them to be automated and maintained in bulk. Morleydev explained how DIP helps templating of tests, I didnt completely understand it because Ive yet to try automated and collaborative testing.

Like many I learned about algorithms very young, and its taken me a long time to appreciate the  terminology of programming architectural understandings. Those were once just known as "high level" or "top down" issues while the interest was in the low level nitty gritty - but Ive slowly come to realize its not just academic showmanship, the formal definitions and paradigms are honed through experience and expertise.
Logged
Klok the Kloker !

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #10816 on: April 12, 2018, 04:18:22 pm »

I may also be crossing a culture barrier here.

In the UK, in all the offices I've worked as a programmer we've only ever referred to "Unit testing" as the automated kind, for example, when talking about coding. Even in casual meet-ups where we're 3 pints down and don't work together so we can say whatever we want xD  But it's still not just British culture, but British Office Programmer culture.

Manually testing with stubbed out parts would just be lumped as a generic "QA testing", or as "Manual Integration Testing". But the manual part is always explicit, instead of implicit, so it doesn't even occur to me to use it to refer to anything else without explicitly saying "manual". Likewise, terms like Mock and Stub and Fake are all used in their appropriate parts with the tools we use (.NET = Moq, Java = Mockito, etc.).

So it doesn't even occur to me for it to refer to anything but that.

In other countries the terms may well be used in 'casual' meaning more often, or the hobbyist community may just not have the language flowing around as much (and me being more a part of the professional community may just mean I haven't noticed that).

As an aside, I recommend heading to some local meet-ups even if you aren't a professional. Professional Programmers that go on their own time to them tend to love what they do, so they'd love to talk to you about it. Hence why I keep popping into this thread xD

As for the use of DI, it's a good way of removing the extra functionality of something from you mind entirely. And if you're doing test-first development (where you write a unit test first, then write the code to make it past) it's very useful for that because you don't need to care what the function does and setting that up, you just need to care about the inputs and the outputs.

As for the value of test-first development, it's a very useful design tool.
* It gives a nice feedback cycle that's satisfying since it gives you tangible progress for code that maybe isn't so visibly rewarding.
* It manages to force you to really think about what you're writing and why, very useful when you're doing it for 7.5 hours a day with only 1 hour break.
* It also acts as living documentation of what the code does, a useful tool for sharing understanding with the next guy to look at your code (or yourself after a few sleeps).
* Documentation that also is self-proving, so if it's wrong the build will fail. Documentation falling out of date is very easy when working 7.5 etc etc.
* It helps catch it when you accidentally break something's contract, also useful when 7.5 etc.

So for programming in a business setting I can't recommend it enough. It's great. Honestly the first point is the real reason people do it, all the others are just icing on the cake. Unfortunately it's harder selling it to managers on the basis of "the warm fuzzy feeling seeing a red test go green gives me".

For casual stuff, that varies from developer to developer. For games, I don't bother except for maybe adding tests for the physics code or some other stuff where my instinct tells me it'll help (unless I'm deliberately experimenting with test-firsting a game, mostly for kicks and giggles. Figuring out some different ways to do tests for graphical rendering stuff was interesting). But for personal API-style stuff, whilst I'm not as strict yeah I try and do it still. Also a useful practice, or try out a new tool before you introduce it to work.
« Last Edit: April 12, 2018, 04:46:58 pm by MorleyDev »
Logged

wierd

  • Bay Watcher
  • I like to eat small children.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10817 on: April 13, 2018, 02:34:42 am »

Most of the stuff I wrote for my employer was that dreadful VBA automation crap for CATIA.  Stuff like "Turn all the spindle statements off, if I forgot to do so on my 500+ operations in my NC program tree, so I dont break a tool."  I say 'oh, I can make a script that does that for you'-- where it iterates over your whole goddamn mess of an NC program, checks the status of the spindle statement boolean, and sets it to FALSE for you in case you forgot. Little things like that. Of course, the object structures for all the part operation modules are undocumented, and there are shitloads of them that can be used-- so I had to spend a few days doing blackbox type probing to find where they hid the damn thing inside each and every one (because they were not consistent).  But it paid off in the end.

Little things like that.  Not some big massive project. I inline documented the object structures, so whoever gets it after me does not have to do the same thing, despite what my co-workers said about it looking unprofessional to have 5kb of comment code in what should be a simple script. I would rather overdocument than underdocument, and it is exactly because I like to sleep between projects, and may need to come back to it for changes later.

But that was some time ago. Some other poor slob is dealing with making automation scripts now. 
Logged

Secheral

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10818 on: April 17, 2018, 05:01:48 am »

Does anyone know of any good CMD tutorials for someone who has absolutely no idea what he's doing?
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10819 on: April 17, 2018, 07:43:55 am »

Do you mean like command line / batch file language?

Generally, you're better off googling any particular thing you need to know (e.g. look for stackoverflow questions asking for what you need to know, cut/paste the examples) or asking questions and looking at small samples, except for the very basic commands. Avoid looking at long lists of commands as there's generally no sensible reason to memorize them (since most of them are kind of pointless to know on a modern OS), the basic half a dozen commands plus examples is what you need.

One option you have on windows is Javascript (or VBScript. But why learn VBscript when you can practice the more portable Javascript). Window's cscript engine runs Javascript natively, so you can make a batch file that calls some Javascript, then you can have a console script written in Javascript, which is a lot more powerful and easy to work with, and doesn't require any special software to be installed, e.g. if you wanted to use Python.
« Last Edit: April 17, 2018, 07:55:32 am by Reelya »
Logged

Secheral

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10820 on: April 17, 2018, 08:05:32 am »

Yeah, that's what I meant. So stackoverflow and samples. And JavaScript. Got it. Thanks for the advice. Are there any larger sources of samples you could direct me towards?
Logged

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10821 on: April 17, 2018, 12:19:25 pm »

CMD or PowerShell? Windows 10 goes out of its way to make it harder to use CMD, so maybe it is time to learn PowerShell instead.

That said, if you really want to learn good ol' CMD, any DOS tutorial will work. CMD and the DOS command interpreter are pretty darn similar. As far as basics are concerned, if you learn one command interpreter you will know enough to use any of them for basic stuff.
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10822 on: April 17, 2018, 12:59:57 pm »

Almost anything is better than Batch. Take it from the guy who had to fix some bugs in a large Batch application ( :'( :'( :'() at work.

Instead of fixing the issues in Batch, I had an easier time translating it to Bash, fixing the issue there, then translating that back.
Logged

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10823 on: April 17, 2018, 01:28:30 pm »

I've been playing around writing a game with the Love2d library in Lua.

I have learned that I don't like Lua much.  Lists start at one instead of zero.  No ternary operator.  No "next" keyword for loops.  No string interpolation.

The Love2d library itself seems pretty nice though!
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

strainer

  • Bay Watcher
  • Goatherd
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10824 on: April 17, 2018, 02:24:19 pm »

Lua is epically efficient, fast and functional though - and no punctuation :D

Batch files - not much is needed to know to do the most useful stuff with them. Their common purpose is for small startup scripts and command aliases to relieve the task of typing all the necessary paths and switches.

That generally looks like:
(file: docommand.bat stored in cmdpath)
Code: [Select]
"c:\path_to\the_command\its_name.exe" /switches /a /b %*

Or if you want the command to detatch from the terminal
Code: [Select]
start "" "c:\path_to\the_command\its_name.exe" /switches /a /b %*

My most 'complicated' batch script is to log short notes into a file with datestamps.
file: jot.bat  ( eg.>jot append this blurb into jot.n)
Spoiler (click to show/hide)

It also not hard to set up the command environment to run python scripts in the same way batch files run, if that's your flavor.

Quote from: Secheral
Are there any larger sources of samples you could direct me towards?
There's probably loads in your system already. Best way to find files on Win is indoobitebly the search tool "voidtool's search everything" (which can also be run in the commandline)
« Last Edit: April 17, 2018, 02:42:52 pm by strainer »
Logged
Klok the Kloker !

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10825 on: April 17, 2018, 04:00:41 pm »

Lists start at one instead of zero.

this is true and it sucks

No ternary operator.

Code: [Select]
a = true and 3 or 4
print(a) --prints 3
a = false and 3 or 4
print(a) -- prints 4

No "next" keyword for loops.

you can just use "else" for that, i think

No string interpolation.
string.format
Code: [Select]
print(string.format("Hello, %s","world!"))
« Last Edit: April 17, 2018, 04:02:27 pm by Putnam »
Logged

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10826 on: April 17, 2018, 04:17:45 pm »

Using and or is cheating.   >:(   :P

I guess I could do string interpolation that way, but honestly it seems like more work than just concatenation at that point.  I'm mostly spoiled by ruby's "This is the #{'best'.upcase()} way to do it".
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10827 on: April 17, 2018, 04:52:18 pm »

Lua's lack of a continue keyword is an abomination and no one has ever given a good reason for it. The best they can work up is "just use goto", but that is a dirty hack at best.

The worst thing about it, is that adding a continue keyword is trivial. My custom compiler has one, and it was no harder to support than break, it certainly didn't need any new instructions or anything like that.

Indexing from 1 is evil too... Honestly, my dream scripting language is Lua, with 0 based tables, continue, and braces for code blocks.
« Last Edit: April 17, 2018, 04:53:59 pm by milo christiansen »
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10828 on: April 17, 2018, 05:58:29 pm »

What, you don't like [[this]]?

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10829 on: April 17, 2018, 08:43:47 pm »

Actually, I want to replace this:
Code: [Select]
a = {"A", "B", "C"}
if a[1] == "A" then
    -- Do something
end
with this:
Code: [Select]
a = {"A", "B", "C"}
if a[0] == "A" {
    // Do something
}

EDIT: Before someone points out that braces for code blocks conflict with braces for table literals, let me point out that I wrote a prototype for this, and that was not a problem. You could always tell from context what was intended, and there were (IIRC) no ambiguous cases and no need for backtracking or anything else. Just plain ol' recursive decent.
« Last Edit: April 17, 2018, 09:04:12 pm by milo christiansen »
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS
Pages: 1 ... 720 721 [722] 723 724 ... 796