Is there any way to learn how to work on code as a group without actually working with anyone else? I've learned git, but I can't think of anything else.
I was just trying to learn minitest from a tutorial online and I promptly realized that I was doing TDD totally wrong. Is there anyway to write good tests for already written code?
The client then talks to a Rails-backed API server to get its data
Basically client connects to example.com and gets html/javascript/css but no data, then the client-side React app boots and talks to api.example.com to fetch the data it needs to show stuff
@meagar thanks.....I understood the flow; I just haven't seen the separation into separate projects/deployment before and thought that's weird. Learned something new
you have to write custom javascript to ensure the correct data is being sent. my suggestion is to have a hidden input with the param name you want. the write some javascript to fill the hidden input with the correct value @Btuman
Sometimes my brain wants to call code "unnecessary" when it isn't. I just had this argument with myself over this code:
def delete_rows(temp_ids)
...
rows_deleted = SqlServer.exec_sql(sql)
rows_deleted
end
This could be written as:
def delete_rows(temp_ids)
...
SqlServer.exec_sql(sql)
end
And the code would do the same thing, but without telling the reader that the return value of SqlServer.exec_sql was in turn the return value of this function, or what that return value meant.
Having return be explicit does help, but the temp variable can still be needed even then. because return SqlServer.exec_sql(sql) still doesn't say what is being returned.
By the way, I've refactored that method so it has only side-effects and no return value. Problem solved.
@WayneConrad im confused.. ruby developers are suppose to know the last thing from the method is returned.. as for clarity, your method name is pretty clear on what it does..
One way of solving the problem is to follow the convention that methods with side-effects are named after verbs; these methods have no meaningful return value. Methods without side-effects are named after nouns; these methods return something. Then the method name tells you whether the method has a meaningful return value or not (and what that return value means).
i think rails docs do this kinda of thing in method comments
example:
# If the first argument is not a Symbol, then it will simply be returned:
#
# ActiveSupport::Cache.lookup_store(MyOwnCacheStore.new)
# # => returns MyOwnCacheStore.new
def lookup_store(*store_option)
I read once that a method should either have a return value (and be referentially transparent), or have side-effect(s), but not both. I cannot find any references to this rule, but want to learn more about it.
What is the origin of this advice? Out of what person or community did it arise?
Ex...