« first day (3163 days earlier)      last day (1768 days later) » 

1:09 AM
hey whats up guys
 
 
1 hour later…
2:23 AM
hey all
is there a way i can recover the untracked files from git
i just did git reset HEAD^
 
2:36 AM
Did term 'database corrupt' is actually because of bug?
Or database can be corrupted without IO error/ software bug/ database bug
Example: User terminate the app that database is currently in writing
While mobile database like mongodb, sqlite, realm are designed be able to terminate
There is really some misconception because they database still can be corrupted without hardware IO error
 
3:37 AM
Without IO Error/ Software bug/ databse bug the possible scenario can be forced termination of an app, some phones do allow that however that is an opinion and should be taken with a pinch of salt
 
4:03 AM
@anand_v.singh are you an expert
 
No not at all
 
 
1 hour later…
5:20 AM
where is @Rob
 
Hmmm It was dangerous to ping people. More dangerous if it was mod.
 
dangerous?
do you about Tap
 
Rob
o/
@c0dem0nkey As far as I know, there's no way within git. However, the files might be in your OS's recycling bin
 
5:42 AM
hey rob
had a couple questions
when using TAP your return has to be another Async method?
and you have to have a return
 
@ChristianMatthew The return type of function us async<Task>
Inside the function however what you return can be an async method, or just a normal variable
 
i keep getting an error that you can't return a normal variable it has to be an asynchronous return i.e. from Task.FromResult() or from another async method
 
Again if you are skeptical of people on the internet, just write a TAP in which it does nothing other than making the thread sleep for 10 seconds and return a variable which is not async
 
static async Task Main()
{
	var test = await FryEggsAsync(2000);
	Console.Write(test);
}

public static Task<string> FryEggsAsync(int x)
{
	string cookingAction = "Frying Eggs";
	var delay = Task.Run( async () => { Stopwatch sw = Stopwatch.StartNew();
                                    await Task.Delay(x);
                                    sw.Stop();
                                    return sw.ElapsedMilliseconds; });

	Console.WriteLine("{0} took {1} minutes to make:", cookingAction, delay.Result/1000);
 
Can you create an MVCE of your function
 
5:49 AM
i did exactly something like that
 
what is the error you get?
 
cannot convert type string to task.task...
the code I just posted works because I am using task.FromResult which provides a TResult result
 
Just do -> return "Eggs are ready";
 
you can't you get an error
it's the same error
 
Rob
What's the problem with what you've got? Seems to work fine?
 
5:54 AM
it does
i just was confirming with you that a Task'd method has to resturn an task result
i.e. the the promise resolve you were stating yesterday
 
Rob
Yes
If the method is marked async, then you can return just the string
And the compiler will wrap it in a task for you
If it's not async, you're just returning a task like any other type of object
 
ohhhhhhh
you're right why is that
so it's just acting like a wrapper
so then can you return any method at that point even if it is not asynchronous
 
Rob
Not sure what you mean by any method?
 
ok from what i see... you can return await (method is async)
can you return await (method not async) or should you return (method not async)
 
Rob
You cannot use await if the method isn't async
 
6:02 AM
got you
 
Rob
Think of it this way. If your method is marked async, anything you return is wrapped in a task
await can be thought of unwrapping the value from a task
So, with those combined, in an async method, you can't simply return a task
Because that wraps it into a Task<Task<string>>
Thus, you return await task. Which unwraps it from Task<string> -> string, then wraps it back up
Slight caveat to the 'you can't return a task'. You could return a Task<string> directly from an async method if your return type was Task<Task<string>>
 
how did you learn this
this is not in the documentation
 
6:19 AM
GoOoOoOoOoOoOoOoOoOoOoOd Mornin' squirrelerinos!
 
so lastly, to the above points, which are golden... if it is not async and you're returning an async method i.e. Task.FromResult() you don't need the async and await because you are getting the TResult result ansynchronus output
 
Rob
@ChristianMatthew Which part isn't?
 
which part ins't?
 
Rob
They're not async methods. They're tasks. They don't need to be async, and they don't need to be methods
Task.FromResult(1) for example, is neither :)
 
mmmmmmmmm
Tasks are asynchronous
 
Rob
6:23 AM
Not necessarily
 
let's say in most cases
 
Rob
FromResult isn't asynchronous
and I believe, c# won't even process it asynchronously. Whoever awaits it will immediately get the value
 
well it's output is
 
Rob
Which is different in javascript, in that even resolved values are not produced immediately on an await
 
yes but without blocking
which lets say that is the overarching definition of asynchrony
all I am saying is that if the Task<string> isn't prefaced with async the Task.FromResult() is a Task based result which matches the intial Task<string> object
do you agree with that?
btw this is golden and needs to be put into documentation
Think of it this way. If your method is marked async, anything you return is wrapped in a task
await can be thought of unwrapping the value from a task
So, with those combined, in an async method, you can't simply return a task
Because that wraps it into a Task<Task<string>>
Thus, you return await task. Which unwraps it from Task<string> -> string, then wraps it back up
Slight caveat to the 'you can't return a task'. You could return a Task<string> directly from an async method if your return type was Task<Task<string>>
 
Rob
6:27 AM
It's right, but it's a round-a-bout way to think about it, I think
Look at these two functions:
public static async Task<string> GetSomeText()
{
	return await DoSomething(); // DoSomething() is defined as async Task<string>
}

public static Task<string> GetSomeText()
{
	return DoSomething(); // DoSomething() is defined as async Task<string>
}
If someone wrote var result = await GetSomeText()
Do you see that for the first method, they're awaiting the task created by GetSomeText by the fact that it's an async method
 
yes but i am learning from error messages lol so it's a little harder
 
Rob
And for the second method, they're awaiting the task created by DoSomething
That is: The first snippet has two tasks. The second is just the one
Indeed, there's no point in writing the first method. You'd only want to return await if elsewhere, you were awaiting a task and using the result
So, to think about whether or not your method needs to be marked async boils down to the question: Does your method need to await a task to get the value?
 
but i don't think method 2 is legal is it
 
Rob
Sure it is
 
is it Async?
i.e. DoSomethingAsync
 
Rob
6:31 AM
No, it's just fetching a task from somewhere and returning it
It doesn't do anything with the task
 
but the return has to be of that Task<string> object type
 
Rob
Yep, because that's what DoSomething is returning
 
so it is async
 
Rob
The second method would be valid even if you completely forget about async/await
It's just a method, returning an object
 
yes but i am saying DoSoemthing is returning Task<string>
is that right
 
Rob
6:33 AM
Yes
Both of them do
 
Rob
The first one returns a task which awaits another task
The second simply returns the 'another task'
 
i would name it based on proper naming convenctions DoSomethingAsync()
cool I understand this a lot better than yesterday
it's a big subject... do you think it is one of the most complex aspects of programming?
 
Rob
If you understand passing around functions, the above is similar to:
public static Func<string> GetSomeFunction()
{
	return () => DoSomething(); // DoSomething() is defined as public static string DoSomething()
}

public static Func<string> GetSomeFunction()
{
	return DoSomething; // DoSomething() is defined as public static string DoSomething()
}
 
so Task is just a delegate
 
6:36 AM
@ChristianMatthew The most complex aspect of programming is naming things.
 
Rob
When I meant similar... I meant it's similar in the fact that it's a task awaiting a task. Same as this new example is a function invoking another function
Versus simply returning a task, and simply returning a function
 
!!funfriday
 
@Rob but i think the user would have to know those things or what to expect when you see something...
 
6:37 AM
morning
 
Rob
Nope, they don't
 
that video is horrible
 
Rob
var text = GetSomeFunction();
Cnsole.Write(text);
In both cases, they write the above. They have no idea if it's a function calling another function, or a single function
Which is the same as for tasks. They simply await the result in both cases
Whether or not the function they're awaiting is marked async
 
@RoelvanUden Not at all, I give support to a webforms whose developer named methods like string GetAge(string param, string param1, string param2, string param3)
 
Rob
I've gotta maintain some code written by a node programmer. Everything is using dynamic
 
6:39 AM
the wrong type returned is a sample of the awful coding
 
Rob
Nancy and dynamic, everywhere
 
I would have a dev that would write nasty if statement's like that. I am like bro if it's not null and has an intended value let them in. You can't control the whole genetic genome in the first if statement
good night
i'll be on tomorrow or tonight
 
Rob
Cya later
 
@bradbury9 Yeah because that makes everything so perfectly clear.
 
hey @Rob sup recovered them
@Rob fortunately didnt do commit.
just did a head reset
 
6:46 AM
To be fair (just checked the email where I said WTF is this shit) the exact signature was: void GetPermisoRequisito(string Id, string Id1, string Id2, string Id3)
In database is decimal? In the code is a string. In database is DateTime? In the code is a string. Im glad he was consistent and strings where declared as string :-)
When rewritting the DAL because of SQLi, I had to add an extension method to handle wrong typed variables making its way into parametrized queries.
public static IDbCommand AddDateParameter(this IDbCommand command, string name, string value) // I has a null ckeck and DateTime.TryParse inside
 
7:11 AM
This is why I said naming things is the most difficult thing in programming. You have to convey the exact function and purpose in the class and method name, and explain just enough so that the caller understands what needs to go into parameters. Naming things is hard
 
@RoelvanUden But won't it make more sense to use <summary> on method calls? :D
 
I added the first <summary> in the whole application. I had to clean some funny code also like DateTime.Now.ToString(0,10) when adding data into the database. That web coder knew little about coding, database design, javascript, css.
 
7:32 AM
I didn't know the As during (re)naming collumns and tables was optional
IMO it makes it super unclear when somebody else wrote a script and they just left out the AS
 
@Raimonds Ain't nobody readin' comments
 
@Raimonds Makes allotta sense
 
7:47 AM
@RoelvanUden Why do they exist than? I do read them all the time its a quick way to understand what function or it's params do
way quicker then .peek it
 
Aswell it helps somebody who isn't sitting in your head to udnerstand what the purpose of a "ParentChildrenLookup" is
 
> The two hardest things in programming are naming things, caching, and off by one errors.
2
 
A comment is only necessary because a function is not self-explanatory enough. Rework the code to be easier to comprehend and give more explicit and self-explanatory names. Needing comments is, crudely said, a sign of bad code readability.
 
Well I don't think .NET framework agrees with that statment
It's so nice to F12 on .net framework libs and just read what that thing does, yur explicit naming might make sense to you but to somebody else will be lost.
 
8:04 AM
morning o/
 
@RoelvanUden I disagree, I like to write comments to simplify things and then only read the comments if I have to look over code as navigaiton points
 
I'm not saying comments are bad. If they give additional information, that's great! But if the comments are saying what the basic function of the thing is, then your naming is off.
 
e.G. // Map Entitiy to PublicEntittiy
[...] 10 lines of mapping code

I know it's considerd as code-smell/comment noise but IMO it's quicker to udnerstand the comment than ponder over those 10 lines to makes sure that everything is just mapping
 
8:20 AM
I just prefer to see and know that everything i need has been mapped correctly
 
@CaptainSquirrel Nooo, not the squirrel!!!!!!!!!!!!!
 
Yeah, there is no reason to comment on things that should be obvious
I have folder for mappings so no need to comment on those ;D
 
@bradbury9 FEAR ME
 
good morning
 
good mornign to you too
 
8:26 AM
I demand fixing. I did too
 
How often do you unit testing your methods?
 
@Raimonds it is even nicer to look at the function name you are calling and understand the behavior without reading 2 pages of documentation
 
It would be overkill for a function to have 2 pages of docs :D
 
@HelloWorld every deploy and every manual test run (approximately 100 times more)
 
@HelloWorld I'm 4 years into software development and i'm yet to run/write a unit test lmao
 
8:27 AM
CreateWebApplication(IList<object> ideas)
@CaptainSquirrel same
I think I don't get them
 
I did mention it at my last place a few months before we went like
and my boss was like
 
what a sad web application, it only contains ideas
 
@HelloWorld often
 
You are more than welcome to spend 6 months writing unit tests for everything
 
Or my level of abstraction is so high that I am testing new code
 
8:29 AM
tbh with the amount of changes the other departments requested, unit testing would be wasted
 
I usually face myself looking at unit test that gets perfect input with no way it can ever fail
 
we just tested everything by hand :D
 
So why am I even testing it
 
My coverage is often really low, but the applications are very thoroughly tested
 
mine is 0 :D
 
8:29 AM
@CaptainSquirrel unit testing is exactly good for changing request environment
 
@Raimonds do you know what a service object is?
 
I know nothing that is theory
 
you have a compiled documentation what your software do
 
give me an example i#ll tell if I know it
 
8:30 AM
@Raimonds how is there "no way it can ever fail"? It can fail if you wrote it wrong
 
service objects are the main target for unit tests
 
That's the point of tests
 
the only documentation we had was all the docs i wrote in the final weeks before i left
 
a service object is a class that has a job
 
emm sum(int a int b)
 
8:31 AM
and 90% of it was to do with the dev environment and how to run builds & deploy etc etc
 
supplying ints
dosn't fail
 
it does if your int is a ""
 
I can check if string will fail and if it does then pass
I am making assumption I am not getting that thing right
 
sum (int.MaxValue, int.MaxValue)
 
What? No, unit tests don't test that you supply the right input
They test that the code does the right thing
I'm not sure how this can be unclear
 
8:32 AM
Based on input you supply?
 
Personally I love having the documentation embedded in the same file as the code. With regions it can be easily collapsed away when not required and it can be automated into other formats such as HTML on build.
 
@HollyStyles /// + tab ?
 
@Raimonds if that method is in a class, then sure, it is a service class (and instances of it are service objects)
 
@Raimonds yes
 
you would write unit tests to validate the result of the invocation
 
8:34 AM
sum(int a int b) can still be tested for BVA
but yes. You don't often do that
 
The test ensures that you did the right thing in the first place and any changes you make in the future don't break that behaviour
 
var a = 10;
var b = 42;
var expected = 52;
var actual  = obj.sum(a, b);
Assert.Equal(expected, actual);
 
like I see no point in that test
 
var a = Int32.MaxInt ...
 
4 mins ago, by ntohl
sum (int.MaxValue, int.MaxValue)
 
8:36 AM
var b = Int32.MaxInt; var expected = ?
 
I know real life code would be more complex, but I think I am oversimfilifying my test so that all starts to look like 52 == 52
 
@Raimonds ok, what if I change the behavior of sum?
 
It's a good point
 
But how do you know that the method you wrote returns 52?
 
@Raimonds I have about 12 years, and only in 1 project I did unit testing.
 
8:37 AM
Not sure who would go that hard to change function so drastically
 
ok... then answer ntohl's version
what happens if you sum MaxValue and MaxValue?
 
Mine is like 6 years comercial and extra 4 like a hobby thing in frontend
stack overflow exception?
 
well... definitely not stack overflow
 
It will throw something like sorry your int is too big for int
 
@Wietlol: Compilation error (line 7, col 21): The operation overflows at compile time in checked mode
 
8:39 AM
it has word overflow in it ;D
 
That's on dotnetfiddle.net
 
that is operation overflow, not stack overflow
 
still exception
Nobody knows them all anyway
I am trying to implement some sort of unit tests, so far I switched to DI, thats about it
 
it doesnt throw any exception at all
 
How would I test service object, should I abstract out all functions inside that are like sideeffects?
 
8:41 AM
the result is -2
 
since I wan't to test particular call not all subcalls what might fail it
 
It isn't always easy to identify what a unit is particularly if your code is framework based where it pops in and out of framework code regularly
e.g. asp.net you don't actually get to see how a request gets to a controller
 
@Raimonds you mean private methods?
 
It's hard to define my test I guess is my issue
 
or you mean service objects of your service object?
 
8:42 AM
My boss said, that i must write unit tests for every method in project, but i have time only for debugging, what should i do?
 
write unit tests for every method in project
(tell your boss ahead of time that your project will take twice as long)
 
@Wietlol Not sure if this is design problem but in most of the cases when method is called with object as a param that object is being tossed around and modified in other calls.
 
ew mutation
 
So should I skip logic in those extra calls and just return object how it should be
 
but can you give an example?
 
8:43 AM
Well you must know what state that object should have when you call a particular method
 
Not really
 
you can try tho
 
unit test for every methods. Then how many methods you have in your project?
 
2036
 
Let's do simple one first, lets say my call has connection to database and it adds extra values to one of complex props of that class.
Should db call be abstracted?
What I see most of the time "abstract db, so no real call is made"
 
8:46 AM
If you just "religiously" test every line of code, you end up with your test code being ~10 times size of the actual code it's testing, requiring 10 times the maintenance and disk space etc..
 
unit tests should reduce maintenance as far as I know, not to increase it
 
what you have is coupled responsibility
you have two concerns here, loading/writing stuff from/to database
 
So should that be reworked in [S]olid
 
and adding extra values to stuff
you generally want two separate service objects for that
(our database service objects are usually repositories)
 
Codebase I am left with is hard to change... there is 700 lines of email logic which from what I can see could be done better
 
8:49 AM
@Raimonds With legacy code (a pile of already written code you now want to test) the best place to start is integration tests not unit tests.
Then you start refactoring an abstracting the dependencies like DB calls.
 
Won't all that knowledge make me a tester soon
 
you are a tester if you are a programmer
 
Not really
I'd call it "tester"
 
but yea, if you want to keep using that codebase, best chances are to change that codebase
 
But there is a job on the market "tester"
so they should be different in some way
 
8:51 AM
so, extract code from god functions into service objects
 
I do test my code, but not how it plays with deepest levels of system
 
most programmers are also testers
 
I would call that job nightmare
well therefor we got automation I guess :D
 
I would call that job Software Engineer
 
Sounds like $$$ :D
 
8:53 AM
not really
 
Probably the hardest part is to start it
 
Good testing is enhanced by being in a different mind-set. When you test your own code you do sum(21 + 21) = 42 because your job is to solve sums, if you are dedicated tester you do sum(int.MaxValue …) = boom because it is your job to break it
 
Having no prior experience in anything makes me really cautious and slow
 
But it's all programming.
 
I've broke so many things that now I am even testing against emojies as an input
well more like I am thinking of what would happen, poop emojie once broke my js :(
In my old place testing was carried by testers
I miss those guys haha
Since I mentioned 700 email logic earlier, which is mostly constructing template based on 10-20 if statements, any suggestion how to avoid if hell?
What it does it basically check for flags on object and then determines what type of email to send, there are places where if statements do repeat because I believe they needed to trigger something after something else was done.
 

« first day (3163 days earlier)      last day (1768 days later) »