« first day (3140 days earlier)      last day (1793 days later) » 

11:00 AM
i stopped because i got borred
thats the only reason
 
 
loool
neil posted some good pics I have to say
 
@AvnerShahar-Kashtan Atleast you can write tests
 
I should write tests. But the class I want to test has explicit dependencies on AutoRest-generated ServiceClient<T>, which is hard to mock.
EF Core 3.0's breaking change is interesting.
 
I've noticed there's a new .NET Framework around the corner, so is it going to diverge and die like VB.NET and C# did? Only the strong survives?
With the amount of trash W10 is adding I wouldn't be suprised if at some point they made Windows 11
As soon as the OS hits enough barriers and they do what they did to god-almighty WinXP
 
11:14 AM
@HéctorÁlvarez .NET Framework is on life support, features of Mono get merged into .NET Core, .NET Core (versions newer than 3) is renamed to .NET
 
@HéctorÁlvarez .NET FX will have v4.9 to pull users through while new projects will use .NET Core 3. In late 2020, .NET 5 should support legacy .NET FX applications and will be the step forward for them - .NET 5 will actually be .NET Core vNext, named 5 to it can continue both .NET Core and .NET FX.
Just like Windows XP was the "next OS" after Windows ME, but technically, it was vNext of Windows 2000, not Windows ME/98
 
@HéctorÁlvarez we have the same thing. Called obj_CodeValues. But there is a cloud design pattern for that as well cloudcomputingpatterns.org/key_value_storage
our obj_CodeValues is historycal, so you can select what were the values in the past
@AvnerShahar-Kashtan which is?
 
@ntohl If part of the query can't be transalted to SQL and run on the server, it silently converts the dataset to an Enumerable, pulls the data to the client, and runs the query locally, warning about the possible problems. As of EF Core 3.0, it will throw an exception.
 
hmm. I hate it, and I like it
it's like implicit conversion changed to explicit
 
> it silently converts the dataset to an Enumerable, pulls the data to the client, and runs the query locally
this sounds utterly silly
 
11:25 AM
@AvnerShahar-Kashtan deprecate all client code
 
no. It was good. You could just declarative programming instead of imperative.
 
@AvnerShahar-Kashtan isnt this older?
 
when you wanted a multi table join where you just mind which columns will be selected, you can do it. If later you add a where filter with a someConstList.Contains, than you don't have to rewrite the whole stuff, but silently it will be done on the client side
 
there were several cases where we got a runtime error "cannot convert IsEmpty to sql" or something like that
 
@ntohl You can do that explicitly - add an AsEnumerable() call which explicitly switches control to the client.
 
11:29 AM
where IsEmpty is a method we defined
the solution in those cases was to use AsEnumerable()
 
But a relatively common error (god knows I've written that code) is where you think your query executes on the server, but some little nuance actually made EF pull it to the client because it can't translate that query, and you can't tell until you're running in production with a huge dataset.
 
or make IsEmpty return Expression...
 
for which, we wrote .AsEnumerable() // dumb EF is dumb
oh, how much I miss SpringRepository
 
I heard that in a conversation, that C# ers have less error from those kind of "what does the ORM pull to the client", than Javers, because we check the generated selects more frequently
Javers just trust the ORM, which generates abysmal selects.
 
depends on your ORM
Spring-Data uses a SpringRepository
which has a very clear distinction between what you have computed locally and what is computed on the server
unlike EF, where it switches half way through your expression chain
both have their pros and cons, but for SpringRepository, you do know what is sql and what is not
 
11:36 AM
We have a Windows forms application that we need to convert to web application, it uses reports heavily .. should we go to .NET Core or the traditional .NET framework?
we are not interested in deploying it in non-Windows servers
 
@Wietlol THAT is the point where you loose what you wanted to do in the first place
 
0.o?
 
@mshwf A brand new web application developed today should be developed in .NET Core.
 
only a brand new web application developed in .net
 
like. Before foreach you saw int i = 0; i < ....Count; i++ and a lot of boilerplate. Hiding the true intent to actually enumerating the effing list.
 
11:39 AM
@ntohl yes?
 
@AvnerShahar-Kashtan is this enough reason?
 
so. With SpringRepo if it distincts between two types of select, you have the boilerplate of where the data coming from. Which you actually don't care in declarative programming
 
it's easy to use SSRS in .NET Framework , but not supported in .NET core
 
it doesnt distinct between two types of select
sort of
 
> which has a very clear distinction between what you have computed locally and what is computed on the server
 
11:42 AM
the difference is that you use methods
 
@mshwf Well, yes, that might be a reason to avoid it. Though I'll be surprised if this situation persists. In any case, it's always possible to run most of your app on .NET Core, and move the specific backwards-compatible bit to a .NET FX service.
 
usersRepository.findUsersByName("Wietlol").map(it => it.length).forEach(it => println(it))
findUsersByName("") < that is sql
.map().forEach() < that is local
the repository contains all methods of how you want to communicate with your database
 
like whereUserIsDeletedTrue()? Which way a filter goes?
 
@Wietlol The selling point of EF (and LINQ) is that it's platform agnostic. You write the same LINQ query over local objects, SQL connections and, say, Active Directory lookups, and the underlying provider translates the uniform langauge to the specific calls. This is LINQ's great differentiator - it lets you use the composable queriesof LINQ over SQL.
 
in declarative programming you effing don't care if it's a where x = 1 in the database or
x == 1 on the client side
 
11:46 AM
Your example seems that require writing specific repository methods encapsulating specific queries.
 
.findUsersByNameAndIsDeleted("Wietlol")
or
.findUsersByName("Wietlol").andIsDeleted()
@ntohl yet, we do care
@AvnerShahar-Kashtan and EF does it really well... except when it cannot convert the expression to an sql expression thingy
 
@Wietlol Well, that's exactly the different philosophies of LINQ-based ORMs vs. whatever you want to call SpringRepository's philosophy.
 
you can postpone the care for that
you have the ability to NOT premature optimize
 
you could also look at it from the other direction
 
@AvnerShahar-Kashtan So is .NET Framework 5 the new candy that everyone will tend to? Or will we get Core to replace FX and Framework to work its way?
 
11:50 AM
your function, which does some weird stuff, needs to load user information from the database, so you do dbContext.Users.Where(x).Select(y).GetStuff().DoMoreStuff() or, you could add a function to your repository that does it
 
@HéctorÁlvarez .NET Core 3.0 will live concurrently with .NET 4.9, and is the recommended platform for new projects and anyone who has the time to migrate. When .NET 5 comes around, it will replace both 3.0 and 4.9, as well as consolidating Mono and Xamarin.
 
everyone will tend to .NET Framework 5, because it will be the next gen for both directions (core/framework)
 
delegating out the loading from the database
 
".NET Framework 5" is not a thing, ".NET 5" is
 
@AvnerShahar-Kashtan Oh great!
 
11:52 AM
.NET Standard Framework Core 5.0
 
Right it's .NET 5, that sounds awkward to pronounce
 
@Wietlol you will write IQueryable<...> DoMoreStuff(IQueryable<...> getMoreStuffResult) at the end. Which all the way down will be mockable by the framework. I mean if you want to mock your from user in Users() where user.IsDeleted select user, you would not have to do anything added to what you already have (mocked dbcontext). But in Spring's way, you would need to write findUsersByNameAndIsDeleted again
 
I wished they invented a better name instead of .NET for .NET core, just look at how we struggle when we talk about .NET core and .NET Framework, also .NET core is still a framework. it was all a mistake
 
and everything should be .net core, but that didnt work out so we made .net standard
vOv
@ntohl that is where the second approach comes into play
> .andIsDeleted()
 
12:05 PM
but you want it to run the stuff DB side in production, but client side in in memory version
without rewriting any of from user in Users() where user.IsDeleted select user
you declared the intent not the how
 
running with an in-memory database or with a db server is really simple in spring
all you have to do is say which driver class you want to use
iirc, h2 for local, and sqlserver or mysql or etc for a db server
or a mongodb
 
@AvnerShahar-Kashtan "move the specific backwards-compatible bit to a .NET FX service." can you provide more elaboration on this please, or any resource?
 
how does spring inform you when something is not implemented. For example in MongoDB, you don't have join
 
it wont use join then
keep in mind, you dont write the implementation of the repository methods
you only provide the interface
you only specify the methods you want to use and Spring-Data will make sure it has an implementation
 
so there will be all possible method on all possible parameter on an interface defining Users table?
 
12:11 PM
not for an in-memory database, not for an sql server database, not for a mongodb server
@ntohl only what you want to use
when you create an interface with the @Repository annotation and it extends any of the Repository interfaces, it knows that you have a repository for a Person (in this case)
then, you can start writing methods
it understands english
 
how does it suggest joins?
 
and it recognizes what properties you have given your models
based on your model class (in this case a Kotlin class)
 
so in case you switch out mysql provider with mongodb provider (prior 3.2), and it will still generate the join methods, because it's based on the model
 
sort of
I have never used joins actually
mostly because you dont program in a relational approach
so you shouldnt write your repository methods in that way
but do you have anything specific in mind?
or do you want a join without a foreign key?
 
umm. Wow. Where does your join goes? In .findAddressByUserByName("Wietlol") or .findUsersByName("Wietlol").Address? Does the latter always end up on client side?
 
12:21 PM
you could do FindUsers().Addresses sure, assuming that your User model contains a property Addresses
 
I want to write from user in Users where user.Name == "Wietlol" join address in Addresses on user.ID equals address.UserID, which still can be extended with anything and being on DB side in production and client side in in-memory.
because I want the minimal optimization of the RELATIONAL SQL database I use, instead of never using joins
 
the other way around also appears to be possible
 
I just downloaded linqpad
 
@mshwf That's a big question, and depends on how your web application's back end is implemented. Our back-end is composed of several services, each communicating with each other via HTTP calls or (more recent services) ServiceBus messages. You can have one such service running .NET FX, and the rest running .NET Core.
 
but it uses underscores
which I find ugly :)
i guess it makes sense at some points
 
12:26 PM
I have a very long "query form" IQueryable. How can I check what will be generated in sql?
 
hmm... Spring-Data does not appear to have its own tuples to deal with composed (joined) results
you have to write your own type declarations for it, but it can do joins using the method approach
 
you have both underscores and ununderscores version. The non underscores is the id? The underscores version is the Address instance?
 
The IQueryable should have a translation into SQL with a lot of variable replacements.
Shouldn't it?
One of the properties I mean
Maybe even the Value, as it will get converted into actual results when materialized.
 
you mean IQueryable<T> have a .Debug property?
 
@ntohl I didnt even see that... im blind
yes, the underscores are entirely optional
> Stream<Address> findAddressByUserBirthDate(LocalDate userBirthDate);
 
12:30 PM
@ntohl IQueryable itself doesn't, since the interface is relatively slim. But the provider might. For EF6, you could set your DbContext.Database.Log parameter to an Action<string> that receives the sql before its executed and can inspect or log it.
 
@mshwf I think ".NET Framework" on its own was a very bad name. ".NET" is awkward in search engines, and it's been a part of their marketing, just like nowadays they stuff everything into "Azure Whatever", they had ".NET Whatever" earlier (see: ".NET Passport"). Only .NET Framework survived nowadays. Also: calling it a framework adds extra confusion on what a "framework" is.
 
@ntohl I only know of a way how to see the generated sql at runtime
dbContext.Database.Log = Console.WriteLine;
 
I used to check the IQueriable SQL when I worked with EF6, so it's possible. It was a property of the instance IIRC.
I warn you though, the translation is far from easily readable.
 
Yeah, the SQL it generates can occasionally be... daunting.
 
12:33 PM
I enabled tracing on SQL side while it was not in production. I saw these translation
 
I mean, it can be terrible to the point where a large EF6 query used to crash because it exceeded SQL Server's limit of query length.
Then some manual fiddling with the query caused it to turn into a query about 0.1 the original size.
 
I heard that in Spring too
tweak somewhere with returning the right Expression<T> can save 90% of the generated code
 
It's probably due to the nature of EF6 making it very comfortable to use selectors and conditions one after another. The abstraction layers sometimes can't easily be simplified.
 
@ntohl Yup. Sometimes even reordering a query - something that should be logically equivalent - can create different SQL.
 
Stuff like queryable.Where(...).OrderBy(...).Select(...) would be built with 3 wrappers around the initial queryable, then simplified only if EF6's optimizer knew a way to do so.
 
12:37 PM
@milleniumbug And I don't know what kind of marketing is this, that thinks .NET is better name for marketing a programming framework!
 
I always type c# or .net, when searching in Google. Framework is too long
 
There was also the issue where a query that took 2 seconds would spend 0.5 seconds selecting data and 1.5 seconds transforming it so EF could relay them to me, and nobody knew why, so I moved to NetHibernate.
 
@ntohl I suppose everyone has the same issue at that point
 
@AvnerShahar-Kashtan well I need to dig more in this especially with SSRS
 
when you want to do stuff that is weird for sql, the query would be weird... and in many cases... big
 
12:40 PM
@mshwf SSRS should be agnostic of the framework you used for your endpoints.
all it cares about is successfully connecting to a data source, and having permission to collect data.
 
12:55 PM
@HéctorÁlvarez the database engine, the designer and working with rdlc files..
 
@mshwf Yeah, but that runs in its own process, doesn't it? Your .NET Core-based web backend simply needs to access it, right? Don't they expose a web-service?
1
A: How to use microsoft reporting services with .net core

darrunateguiSSRS offers a report execution web service that allows developers to do exactly what you're trying to do. In fact, the ReportViewer control that you were previously using is most likely using this web service behind the scenes. This means that it is still possible to render a report remotely, but...

 
I don't understand, how are you separating the .NET Core web app from the reporting service? How doesn't SSRS rely on the web app?
you don't mean a web service/ web api.. right?
 
> enters chatroom
> discussing SSRS
> leaves chatroom
 
SSRS itself - the service that's part of SQL Server - exposes its own web services.
 
1:02 PM
FWIW all of our SSRS reports are generated by opening a particular URL in IE. The only thing our application has to do is figure out the parameters to pass
 
@mshwf If you want to call SSRS from your Core app, all you have to do is call the service and it will spit the result, the implementation doesn't depend on your platform or framework. If you want to call a Core service from SSRS (IDK if it's possible) to retrieve data, you call it the same way whatever the framework is as well.
 
it is possible
your project should have connectedServices ... add it as WCF service and link it to ReportExecution2005.asmx
 
@AvnerShahar-Kashtan where are the RDLC files where I design reports?
 
Haven't a clue. Never used SSRS. Where are they now?
 
what's your approach to design reports?
 
1:12 PM
To get someone else to do it.
 
With asp.net core we can create web application that we can access from linux or mac
but with .net framework we can even access it from linux/mac
Is it correct ?
 
@ILoveStackoverflow whuh?
 
A wild question appeared!
Question used confusion!
It was super effective!
 
@mshwf We have some reports in our app, based on PowerBI. Basically our side of the issue is using PowerBI's Javascript embedding library.
 
1:14 PM
I mean mvc web appication created using .net core can also be access from linux/mac using url
 
HTML and CSS!
but RDLC are much simpler, yes less attractive but get the job done
 
@ILoveStackoverflow You can access it from any place, server back-end frameworks only require that the SERVER fits the platform requirements.
 
@ILoveStackoverflow you mean hosted?
 
@ILoveStackoverflow Web applications can be accessed by anyone. Windows, mac, linux. That was true for pre-.NET ASP as well. The back-end simply generates HTML and CSS and Javascript which the browser parses.
ASP.NET (and the .NET Framework in general) only ran on Windows servers, but the clients were irrelevant.
 
Lets say SO is created using mvc (.net framework) so i can access it from linux/mac also right ?
 
1:15 PM
ASP.NET Core can run on .NET Core, which can run on Windows, Linux or Mac servers.
SO is created using .NET Framework.
Not sure about the front end, though.
 
If SO is created using .net framework then How can i access it from my MAC book?
I dont understand this "RUN"
 
2 mins ago, by Avner Shahar-Kashtan
@ILoveStackoverflow Web applications can be accessed by anyone. Windows, mac, linux. That was true for pre-.NET ASP as well. The back-end simply generates HTML and CSS and Javascript which the browser parses.
 
Using Safari?
 
Rob
Because your macbook isn't running the server code
 
Yes using Safari
I guess you guys are talking about hosting on non windows platforms
Is it correct?
 
1:18 PM
your safari isnt running the server
only the client
 
StackOverflow isn't something you "run" on your computer, the .NET part is hidden from you.
 
for example, your C# code is ran on the server, your JS code runs on the client
 
.NET Core can be hosted on non-Windows platforms, yes. .NET Framework can't be. Yes. But this has nothing to do with your macbook, which isn't running .NET Core, .NET Framework or anything of the sort - it's simply accessing a web site and processing the HTML it receives.
 
When you say run on "Linux or Mac servers" it means we can host application creating using .net core on Linux or Mac servers
Is it correct?
 
1:22 PM
Like we host mvc application on IIS in windows,Linux/mac servers have IIS?
Is this hosting process same for linux/mac servers too?
 
Just found this in some old code, bit baffled by it. What's the point of the wrapper around a static variable here?
 
IIS is Internet Information Server, the specific HTTP server that comes with Windows Servers. So no, there's no IIS on Linux or Mac. There are other HTTP servers.
Not all MVC apps on Windows are served by IIS, either.
 
@ILoveStackoverflow No.
 
	public class MySettingsClass
	{
		public static string ProcessId { get; set; }

		public string ProcessIdentifier
		{
			get { return this.ProcessId; }
			set { this.ProcessId = value; }
		}
	}
 
@MattThrower that's the default getter-setter behavior. You can overload it with your logic.
e.g.:
 
1:24 PM
@MattThrower I'm not sure. Maybe there was an interface implemented in MySettingsClass?
 
@AvnerShahar-Kashtan Are there any other http server like IIS available for windows ?
 
@ILoveStackoverflow Yes.
 
	public class MySettingsClass
	{
		public static string ProcessId { get; set; }

		public string ProcessIdentifier
		{
			get { return this.ProcessId > 0 ? this.ProcessId : 0; }
			set { this.ProcessId = value; }
		}
	}
 
Can you name anyone?
but i guess IIS is the preferred choice and most popular
 
Wait you said "Static"... Ah I'm tired
 
1:25 PM
@ILoveStackoverflow I can, but at this point you really can do a very simple google search.
 
Right it looks like it wasn't static at first and those guys forgot to replace code.
 
All right but why someone would prefer another if IIS is already being shifted with windows server at free of cost?
Is it due to cost or may be efficiency or so
 
@HéctorÁlvarez I don't think so - both of these are properties, so you could simply add logic to ProcessId. I'm wondering if it was originally static, but then they needed it non-static (to implement an interface, perhaps), and added a second property to present teh static var as non-static.
 
@HéctorÁlvarez Ah okay. So it's just written out longhand here? Thanks.
:4629070 Nope. No interface
 
IIRC you can create that using the propfull snippet, it's possible they just left there just in case? IDK
 
1:27 PM
Check out the usages of those two properties, then.
See what uses which and why.
 
@AvnerShahar-Kashtan Isn't that what I said? (legit question)
Oh wait you're right, both are properties
 
@HéctorÁlvarez No, you implied that the static ProcessId is the auto-generated backing field to the ProcssIdentifier, which it isn't.
 
Yes I noticed after pressing enter.
Alas, I'm actually tired.
 
@ILoveStackoverflow Internet Explorer is provided free and built in. So is Windows Media Player. So is MSPaint.
 
Actually I am wondering why someone will prefer something else over IIS which is very powerful
 
1:30 PM
@AvnerShahar-Kashtan Side note, WMP isn't available built-in for N versions of the OS.
You are required to download the Media Feature Pack in order to install the whole media suite for them.
@ILoveStackoverflow $$$$ because Windows Server is expensive and Linux Server is free as in beer.
 
@ILoveStackoverflow simplicity
Im hooked to serverless because of its simplicity
you just tell it where to upload, and it works
 
@HéctorÁlvarez nice dodge
 
I was not knowing that linux is free
That is why people prefer linux over windows server
Now i get it :)
Hehe
 
That's certainly not all.
 
and not entirely true
 
1:35 PM
'till tomorrow lads and ladies, I'm off
 
Ok I found 1 : Apache Http server
Also Nginx
 
Even if you already have a license for a Windows server, there are many use cases for preferring something over IIS. IIS is a beast, with many features to configure and manage. A simpler server which still answers your needs can be a lot easier to maintain.
If you have both Windows and Linux servers, running Apache on both can make life easier.
A specific web application might work better on a specific web server.
 
Does that means(IIS is a beast) IIS is very powerful(can handle huge amount of request easily) than other server for instance Apache or nginx?
 
IIS is a full-featured web- and application-server that's certainly comparable to other top-tier servers, like Apache or Nginx.
 
It's almost as good as freeware
 
1:41 PM
Is this a valid statement that "IIS can handle huge amount of request easily than other server like apache or nginx?
 
IIS is usually late the party on features
 
that is not valid English
 
It's Presidential >_<
 
I would consider all three of those top-tier web servers. I wouldn't try to rank them, because there are too many factors involved.
 
1:44 PM
Whats the first factor or most important factor to consider while choosing web server?
 
@ILoveStackoverflow nginx is usually considered the best web server for its sheer speed and variety of features (incl. load balancing, reverse proxying, etc)
 
Seems like nginx is the best and popular
 
@ILoveStackoverflow if it supports what you want of it
 
You basically just choose what you are comfortable with and can maintain.
 
1:45 PM
for me, what I want is something none of them provide, so all are a bad solution for me
 
Or, don't bother and let cloud handle it for you.
 
Apache server can handle .net application and run on windows?
Sorry if this is a stupid and silly question
 
.NET Framework? No. .NET Core? It can host itself in Kestrel, no extra webserver necessary.
 
^
 
If i have .net core application but windows server than can i install Apache server on windows server?
 
1:48 PM
Ya you can
 
Why would you do that? Windows Server has IIS. Apache brings no benefit over IIS tbh.
And besides, again, you don't need a webserver for .NET Core apps (it uses Kestrel)
 
For the same reason he's asking these questions.. B/c you CAN
 
All right
Thank you so much guys.This has really clear alot of my misconceptions
and also it was good knowledge :)
 
It's a full blown web server. You can run your ASP.NET Core application using just Kestrel.
I just read this line on 1 answer on SO
Does kestrel comes by default with windows?
Like for eg I have a laptop and I created a simple demo .net core mvc application and when I run it ,Where is kestrel
Because i still see the IIS in system tray
 
2:00 PM
@AvnerShahar-Kashtan sorry for pinging you again 😁, two points need to understand, 1. Do you really design reports in HTML & CSS? 2. Do you get the report data from a web API (then you load data in-memory) pass these data to the report (the HTML page)?
 
@mshwf No, I don't design reports at all. People who do do it with SSRS or PowerBI or some other reporting platform. These usually expose a simple embedding mechanism, which I use.
 
o/ been a long time, hope you're all well :)
I've been trying to pick up the factory method pattern. I think I have used it or at least worked with it in a code base a few times before but I'm trying to further understand it, at least so that I'm confident enough where to apply it or be able to talk about it fluidly. Been looking at a few youtube videos and have read a tutorial (with a follow project) to understand it but I think I'm not really any better off, any ideas on what else I could do to try and grasp the concept/problem it aims to solve?
 
new Money(119.99)
vs
Money.OfEuros(119.99)
 
@AvnerShahar-Kashtan Thanks for the help!
 
Money.OfDollars(134.99)
factory methods provide a meaningful overloading feature
other than that, factory methods are not bound to be of the type Money
 
2:05 PM
147
Q: Design Patterns: Factory vs Factory method vs Abstract Factory

Just_another_developerI was reading design patterns from a website There I read about Factory, Factory method and Abstract factory but they are so confusing, am not clear on the definition. According to definitions Factory - Creates objects without exposing the instantiation logic to the client and Refers to th...

 
mr5
Factory pattern is bad and you should feel bad
 
something that comes to my mind is our Optional<T> type (similar to Nullable<T>)
 
eh
 
I guess it's also about "factory method" vs "factory"
 
Optional.Empty() returns an instance of EmptyOptional
Optional.Of(x) returns an instance of SomethingOptional (I forgot the name)
 
2:06 PM
factory pattern is good.
 
@Wietlol - Database.SqlLogger("Log stuff") or Database.EmailLogger("Log stuff") ?
 
for example
i assume that in some cases, you might want to extract stuff to parameters tho
 
@JARRRRG resolve _logger in constructor, than use _logger.Error("Log stuff") like everyone else
or ILogger _logger = NLog.LogManager.CreateLoggerForClass();
 
but then what's the difference between factory method pattern instead of using a DI container?
 
DI is when you dont care about the implementation
 
2:10 PM
I feel like I'm missing the point completely
 
Factory Pattern is when you do
or when DI is weird
 
it's the matter of 2 things. One is, how deep you want to define the DI bindings. For example you can cut the DI graph at a depth level, and only use factories down there. The other thing is some constructors have unresolvable dependencies. For example a data from a csv file.
 
mr5
DI (or IoC) is when you let other handle the object lifetime responsibility.
In factory, all are singletons.
 
Right, so in a factory you declare different ways of setting up a logger instance for example and it essentially provides you a method to set up these custom instances, easier? without having to do it in your calling code?
 
@mr5 all are transient
 
2:13 PM
@mr5 fair point there, the container is managing the lifetime but I digress, they're not solving the same problem
 
@JARRRRG loggers are a different beast. Most of the loggers have config files, which are read without your reach to wrap your constructor around
so you change the config from target name="file" to email, than it's constructing different logger for you (the method in factory method has been set)
 
Is it a valid statement to say something along the lines of: A factory allows you to instantiate instances of similar objects without having to worry about their individual setup/dependencies so that you aren't repeating code?
Right yeah, so the factory is responsible for all the construction and none of the classes using the instances.
It's like construction middleware
 
yes
 
Fair does
 
all factories+ even IoC is construction middleware
 
2:17 PM
See this is stuff I've already done, just never really referred to it as a factory - kinda just see this stuff in projects and then start doing it without ever understanding it
 
@JARRRRG That's what design patterns are - they're observations that people made of how developers commonly do things, and then formalized by giving them a name and a common description.
 
Suddenly saw a project with a bunch of 'Factory' flying around in the class name and thought that I'd try understand it properly from the theory point of view.
thanks - ill have a read (y)
 
"Rules of thumb" part makes your head spin, but very informative
 
principles are far more interesting... and far mor spinny
 
2:22 PM
SOLID was much more comprehensible than why should I use factory method instead of factory.
 
a factory compared to a factory method is when your factory method is based on state
or when you need to pass that factory method around
but the latter is now a bit obsolete because of functional programming
 
which should be used in which case? In real life cases
 
use factory method,
if factory method is not sufficient, use a factory object
 
SOLID is much more stuck to the ground. You can always find an example easily
your Logger example was factory instead of factory method
 
you mean like NetworkStream?
liskov?
 
2:26 PM
why?
 
:p
 
that's just a plain bad Liskov application
 
isnt that a good example?
another one that comes to mind is Convert
 
no need to talk too much about. We agree on that. But when to use factory method vs factory is much more questionable
 
i think its pretty straight forward
favor factory methods for simplicity
 
2:28 PM
Convert is also factory. Why not factory method?
 
use factory objects when your factory needs state or needs to be passed around
(the latter could also be satisfied by a singleton)
 
ConvertFactory.Convert<ToWhat> = x => switch case on typeof(x) ... would be the factory method
or something like that
when you passing the method to convert, it's the factory method
 
Convert cannot be a factory, because you cannot make an instance of that class
 
all right. So new ConvertFactory<ToWhat>(x => switch case on typeof(x) ...).Convert(fromWhat)
 
that would be a factory
 
2:38 PM
200
A: Design Patterns: Factory vs Factory method vs Abstract Factory

Anders JohansenAll three Factory types do the same thing: They are a "smart constructor". Let's say you want to be able to create two kinds of Fruit: Apple and Orange. Factory Factory is "fixed", in that you have just one implementation with no subclassing. In this case, you will have a class like this: cla...

I use Factory most of the times in the linked solution. So you suggest that to define a new subclass, or giving a delegate for the FruitPicker
which is IMHO what have changed with "functional" programming
 
I rarely use a factory nowadays
ive considered one recently tho
we still dont know what we want to do with that mess
also... I guess I misinterpreted "factory method" with "static factory method"
didnt knew they were two different things
 
nor factory method nor factory emphasizes on lifetime. They both should use for Transient lifetimes for least astonishment. Static factory method looks like something that want to handle lifetime (for example load balance)
 

« first day (3140 days earlier)      last day (1793 days later) »