#Factory design pattern

1 messages · Page 1 of 1 (latest)

flint bison
cobalt boneBOT
#

<@&987246399047479336> please have a look, thanks.

flint bison
#

how do i make it so the factori design pattern

#

can have input from the user

#

and input it

abstract nacelle
abstract nacelle
# flint bison

And you can't do that indeed
What are you trying to do?

flint bison
#

im just practicign

#

a factori pattenr

#

i couldnt find an example

#

so i made on in mu head

flint bison
abstract nacelle
abstract nacelle
flint bison
#

i am practising

#

tell me better wau to practise

#

is there a reference or resource

#

for this

open ridge
buoyant cove
buoyant cove
open ridge
#

My second link got removed

#

I linked the other factory method pattern on that site as well

flint bison
#

dw i saw it

#

thanks bro

#

its reallu helpful site

flint bison
#

do u have things like problems to practise design patterns with @open ridge

buoyant cove
#

study on how the pattern is useful

flint bison
#

i understand

#

when its 1 like 1 product

#

that can be divided into multiple implementations

#

each with their own behaviors

buoyant cove
#

its a factory, like irl

flint bison
#

true

buoyant cove
#

you need to spawn some objects

flint bison
#

ja

buoyant cove
#

so you'd use a factory in situations where a factory would make sense, where you need to spawn many objects

#

constructors are strict, factories have flexibility

flint bison
#

true

#

but factories

#

use constructors

buoyant cove
#

yeah, they hide the constructor usage

flint bison
#

but its encapsulated bu the factoru method

#

ja

buoyant cove
#

yup

flint bison
#

is there a site for java problems

buoyant cove
#

the factory could use a constructor. or maybe it uses IO. or maybe it uses reflection

buoyant cove
#

for code design, i dont know of any

#

for algorithms, there are tons

flint bison
#

true for algorithms there are lots

#

for competitive programming

buoyant cove
#

yup

flint bison
#

hard to find design pattern problems

#

😦

#

is this good implementation

buoyant cove
#

Square seems to require some data

flint bison
#

changed the null to throw an exception

#

true i was tinkering with it a bit

#

but ignore the square constructor missing the dimension

#

is this a good implementation

#

of a factoru

#

pattern

#

got a shape superclass interface

#

implemented bu 2 subclasses square and rectange

#

then a creator class

#

with the factoru method

weak fiber
#

The safer way to compare two strings is to use "square".equals(name), then you remove if(name == null)...

flint bison
#

whats the difference between name.equals"square"

#

and the other one

weak fiber
#

if you check name == null?it's no difference, so that's a safer way to avoid nullpointer exception

buoyant cove
#

since "square" cant be null, you wont encounter an NPE

#

equalsIgnoreCase checks for null

flint bison
#

ok thanks

buoyant cove
flint bison
#

hello want to make it

#

so when i do this method

#

the subscritption plan is cancelled

#

so it becomes null

#

is this a good wau

cobalt boneBOT
#

Factory design pattern

#

Changed the title to Factory design pattern.

cyan elk
# flint bison the subscritption plan is cancelled

= null does not cancel the subscription.
it just changes the value of the local variable to null
the SubscriptionPlan object still exists
if you want to make some sort of cancellation, you need to change some state