Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

09-14-2016 , 02:24 PM
(I've written probably 300 API tests since I started here, at least doubling the testing, there are still plenty of untested or nearly untested endpoints)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-14-2016 , 02:29 PM
Quote:
Originally Posted by RustyBrooks
We have a ****load of tests, that's not really what I'm asking about.

What I want is tests that are either generated directly from the API description/documentation, or generated from it with very little directed input. The reason for this should be obvious: documentation is practically useless if it isn't enforced, and if it can't be automatically enforced, it won't be.

You can use tools like, for example, "abao" to do very basic RAML testing. It'll go through your RAML doc, call every API endpoint that it can with the given example, and verify that the return matches the expected schema.

That's actually not a bad start except that it does not check the return for correctness aside from it having the right form, i.e. matching the schema. But your API could return the correct form and still have bugs. Like say you had a delete function that returned the right data but didn't actually delete anything.

So I'd like some way to write "stories", i.e. a sequence of API events and the outcomes that should be expected. I had sort of hoped that some doc languages did this, but none that I have seen does. (My prototype did, but, like I said, they want something standard.)

I'm still looking for a tool that will let me do this with minimum hassle.
Our tests are generated by some custom code a guy before me wrote to create boilerplate for a swagger-express-mw based node app. Then we flesh out the business logic, data access, and testst. So at least I don't have to write that nasty Regex stuff from scratch every time. The code I posted was largely generated.

As far as validation swagger-express-mw does a check of the return data and input data against the model or field, and throws a validation error if they don't match. IE - required field is missing.

Last edited by suzzer99; 09-14-2016 at 02:51 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-14-2016 , 03:00 PM
Right, that part is easy, what I want is more than that
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-14-2016 , 03:06 PM
At least in our app, I don't see how it could be any more automated w/o the generator having to guess at your business logic and back end data access logic.

What else exactly are you trying to automate?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-14-2016 , 03:25 PM
Well, RAML lets you give an example return document from a call. A good start would be validating that the values returned are what you expect - not just whether the fields exist and are the right type, but whether the values are correct. It should/could use the example document to do this but I have not seen any RAML testing frameworks that do this.

In my prototype I had something I called contract. They basically defined flows of data, along with specific guarantees. For example, consider an "add user" contract
a) get list of users
b) add user Alice
c) get list of users
d) new list of users should be same as first list of users, but include alice
I would cobble together these tests by using the examples that I provided with the docs, plus a little glue (i.e. constructing the test for d from a + b)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-14-2016 , 07:07 PM
Quote:
Originally Posted by RustyBrooks
I bought my mom a gps once because she likes to go places, but gets lost and then gets anxious about going places.

She literally didn't open it for a year because she thought it would be complicated. She waited for me to visit and have time to "show her how to use it"

I said, ok, let's do it. She takes it out of the box, plugs it in, presses a button and starts typing in an address. Naturally, it works fine. She was like, "oh, I just thought it would be hard"

In my secret thoughts I hope that this is just because she and I are different kinds of people, and not because being old is sort of hard, because I would really prefer to not be as out of the mainstream tech-wise as my parents are.
I bought my first computer about 6 years ago. I had to go to a friend's house to figure out how to turn it on. Granted, this wasn't a matter of pushing a button, but still...

I got my first office job 5 years ago, which required me to turn on the computer when I walked in. I took a deep breath, pushed the power button, and prayed. Miraculously, the computer booted up entirely, and I'm sure I'd have no clue what went wrong if the screen power button wasn't on that morning. I was now amazing at computers in my little world (holy ****, I can turn one on!), but that day... I was using Excel and Illustrator. I never used the former and never knew the latter existed. The only thing that saved me from not being fired on day 14 was crying my eyes out when the owner told me the bad news.

Technophobia is a real thing, but it can be overcome with persistence.


Quote:
Originally Posted by Prickly Pear
Anyone here every have issues with rsi/arthritis? My index finger swelled up a few months ago and still isn't quite the same as on the other hand (no pain though). Recently some tendon in the palm of my hand became painful and swollen. I'm kind of panicking because my mom has rheumatoid arthritis and just hoping it's RSI from using the mouse all dayand not something less serious.
mechanical keyboards, seriously. My hands used to burn every night and I did contrast baths to get through the pain. That $140 was the best money I ever spent. (also, minimize mousing)

But why aren't you seeing a doctor for this? This sounds serious. They can, at the least, give you medicine, some advice, and perhaps prescribe Rolfing.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-14-2016 , 11:07 PM
Quote:
Originally Posted by candybar

It's like nothing is knowable, everything is controlled by somebody else and giving up is the only way. I guess that's not the worst way to live and there are bigger problems in the world
I feel like you have misread me. The one thing I absolutely hate to do is give up. You only give up when marketing and management has merged their range (imposed the impossible on you). Either one of them individually imposing some set of restrictions on new product is (at worst) hard to overcome. It's when they unite that it becomes exceedingly hard (or impossible).

Quote:
Originally Posted by candybar
In my experience, becoming a good, effective programmer is directly correlated with having the exact opposite attitude. Everything is knowable, everything can be controlled and you never give up.
Everything is knowable in time. Key phrase here is 'in time'. Given my current knowledge, those weird column duplicates wouldn't have been an issue because i know how most things work now. Keep in mind that when i was assigned this task of migrating over lots of legacy PHP I knew basically zilch about how everything was setup/organized.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-14-2016 , 11:43 PM
Quote:
Originally Posted by Craggoo
The one thing I absolutely hate to do is give up.
Quote:
Given my current knowledge, those weird column duplicates wouldn't have been an issue because i know how most things work now..
That's great to hear! Keep it up
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 12:12 AM
Quote:
Originally Posted by candybar
That's great to hear! Keep it up
The fact that i know how stuff works now does not excuse the fact that the **** that tripped me up originally still exists. In my quest to refactor legacy code, I still find columns that serve no purpose. Literally, 100% of the values in that column are identical.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 12:23 AM
Quote:
Originally Posted by Craggoo
The fact that i know how stuff works now does not excuse the fact that the **** that tripped me up originally still exists. In my quest to refactor legacy code, I still find columns that serve no purpose. Literally, 100% of the values in that column are identical.
It seems like you're in a good position to fix it!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 01:34 AM
Quote:
Originally Posted by candybar
It seems like you're in a good position to fix it!
In order to get it fixed, I would have to put in a request to one of the dba's to fix it. I can't even get permission to fix things that make less than no sense in my own department (ui). I think you make the assumption that 'hey something that makes no sense go fix it!'. That's not how it works. It's very very very hard to get something changed unless it literally breaks something in production. This is a case where it breaks nothing... its just stupid and ****ed up. I have pointed out several things that fall in the "stupid and ****ed up" category. To date, i have created branches for all of the cases like that. They all sit unused in branches that may some day get merged into master. It massively irks me that I can sit around all day fixing broken pages and never have any of those fixes make it into production because they generally address edge cases that I happened to discover but customers are unlikely to discover.

Last edited by Craggoo; 09-15-2016 at 01:40 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 02:38 AM
This is from my textbook:


The author is incorrect here, right?

edit:


This compiled just fine for me. Am I doing something different from him? (the green swiggly is just b/c it's never used)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 02:54 AM
Yes, you are. To be doing the same thing as the author, you would have to do something like

Code:
public Form1()
{
  const int C = A;
  const int A = 20; // this is the missing piece, duplicating the class member declared above
I still don't know if he's right because I don't make a habit of duplicating member names as local variables in my C# code, but that's the difference.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 03:00 AM
Quote:
Originally Posted by goofyballer
Yes, you are. To be doing the same thing as the author, you would have to do something like

Code:
public Form1()
{
  const int C = A;
  const int A = 20; // this is the missing piece, duplicating the class member declared above
I still don't know if he's right because I don't make a habit of duplicating member names as local variables in my C# code, but that's the difference.
Ahhhhhh okay. So the line that he says is invalid is only invalid because of the line which follows it. If you comment out the next line, the line he said is invalid becomes valid (I tested this by doing the commenting out). However if you leave it the way he wrote it and changed M = N to M = this.N it is fine.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 03:33 AM
So would that code be valid in C++ and Java? If so I think C# has that right, I mean there are zero positives for allowing partial block scope, it just provides an extra opportunity to write bugs into your code. Obviously TRWTF here is using the same name for two variables.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 03:42 AM
Quote:
Originally Posted by ChrisV
So would that code be valid in C++ and Java? If so I think C# has that right, I mean there are zero positives for allowing partial block scope, it just provides an extra opportunity to write bugs into your code. Obviously TRWTF here is using the same name for two variables.
Not sure I'll try it later. Although this could be used as an argument for making more use of the "this" keyword even when you think it is redundant or obvious. If you use "this.N" in the examples above it works fine and will compile.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 03:43 AM
Is this an okay way to think about dynamic scoping vs static scoping?

Static scoping uses the outer-most variable (when ambiguous)
Dynamic scoping uses the inner-most variable (when ambiguous)

also, why not just disallow ambiguity and be done with it? I guess if you import a library and were no longer allowed to use any name that was used in that library that would be annoying. but you could just say "u need to use lib.name or this.name, because using name is ambiguous"
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 08:43 AM
Quote:
Originally Posted by Ryanb9
Not sure I'll try it later. Although this could be used as an argument for making more use of the "this" keyword even when you think it is redundant or obvious. If you use "this.N" in the examples above it works fine and will compile.
Personally I start all my member variables with an underscore, so the question never arises. That's personal choice though.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 09:43 AM
Start them with $ because then they are cash.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 10:02 AM
Quote:
Originally Posted by Ryanb9
Is this an okay way to think about dynamic scoping vs static scoping?

Static scoping uses the outer-most variable (when ambiguous)
Dynamic scoping uses the inner-most variable (when ambiguous)
That's incorrect. One simple way to think about it is:

Static scoping uses the callee's scope
Dynamic scoping uses the caller's scope

For example,

Code:
const x = 5;
func f() {
  return x;
}
Code:
const x = 4;
y = f();
With static scoping, y will be 5 - with dynamic scoping, y will be 4.

This is a completely settled debate btw - static scoping (more commonly called lexical scoping iirc) has won.

Quote:
also, why not just disallow ambiguity and be done with it? I guess if you import a library and were no longer allowed to use any name that was used in that library that would be annoying. but you could just say "u need to use lib.name or this.name, because using name is ambiguous"
You can't do recursion if you disallow all ambiguity with dynamic scoping.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 10:31 AM
Quote:
Originally Posted by ChrisV
So would that code be valid in C++ and Java? If so I think C# has that right, I mean there are zero positives for allowing partial block scope, it just provides an extra opportunity to write bugs into your code. Obviously TRWTF here is using the same name for two variables.
Edit: I misread the earlier example - so I'm talking about something related, but different.
Edit: And looks like this behavior is the same as in Java.

It's interesting because C# has proper block-level scoping in terms of language semantics but disallows the same name in a method. This works as expected:

Code:
using System;
using System.Collections.Generic;
					
public class Program
{
	public static void Main()
	{
		var list = new List<Func<int>>();
		for (var i = 0; i < 10; i++)
		{
			var j = i;
			list.Add(() => j);
		}
		list.ForEach(f => Console.WriteLine(f()));
	}
}
=>

Code:
0
1
2
3
4
5
6
7
8
9
The only way this can work is for each iteration of the loop to have a separate block scope. The pre-ES6 JS equivalent would print 10's because it doesn't have block-level scoping. From a language design perspective, it's interesting because C# is checking for and disallowing things that are perfectly unambiguous from a language standpoint because they thought it may be confusing for the developer. It's like a built-in lint.

Last edited by candybar; 09-15-2016 at 10:49 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 10:39 AM
Quote:
Originally Posted by ChrisV
So would that code be valid in C++ and Java? If so I think C# has that right, I mean there are zero positives for allowing partial block scope, it just provides an extra opportunity to write bugs into your code. Obviously TRWTF here is using the same name for two variables.
In C++ and Java, are they hoisting the other declaration up or simply translating the former into this.N? The former makes sense, the latter doesn't.

Edit: Looks like they are translating the former into this.N. Maybe this looks insane to me because I spent too much time in JavaScript.

Last edited by candybar; 09-15-2016 at 10:53 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 10:54 AM
They're translating the former into this.N, I assume. That's what the author meant by "whole-block scope", i.e. in C# N is in scope for the whole block, yet not declared, whereas in Java/C++ N is only in scope after being declared, prior to that "N" means this.N.

It might "make sense" but it seems pointless and an invitation for bugs to me. Intuitively it seems to me like a whole block should operate with the same scope.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 11:00 AM
Quote:
Originally Posted by Craggoo
In order to get it fixed, I would have to put in a request to one of the dba's to fix it. I can't even get permission to fix things that make less than no sense in my own department (ui). I think you make the assumption that 'hey something that makes no sense go fix it!'. That's not how it works. It's very very very hard to get something changed unless it literally breaks something in production. This is a case where it breaks nothing... its just stupid and ****ed up. I have pointed out several things that fall in the "stupid and ****ed up" category. To date, i have created branches for all of the cases like that. They all sit unused in branches that may some day get merged into master. It massively irks me that I can sit around all day fixing broken pages and never have any of those fixes make it into production because they generally address edge cases that I happened to discover but customers are unlikely to discover.
You have to fix the process first - it's likely that the reason why you can't get the permission to fix things is that the process is broken. It's likely that within the process they have and the view they have of you, it's rational not to allow you to fix things like this because you or others can't prove to them that the fix won't break the application.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-15-2016 , 11:04 AM
Oh just realized you were saying that translating to this.N doesn't make sense (or maybe I read it right first time and you ninja edited?). Anyway yeah, I agree, interpreting it as this.N offers zero advantages and plenty of scope, no pun intended, for horrible bugs.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m